Skip to content

fix: update mappings for AWS Provider v6 compatibility #902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions docs/rules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,14 @@ These rules enforce best practices and naming conventions:
|aws_dms_endpoint_invalid_endpoint_type|✔|
|aws_dms_endpoint_invalid_ssl_mode|✔|
|aws_dms_replication_task_invalid_migration_type|✔|
|aws_dms_s3_endpoint_invalid_canned_acl_for_objects|✔|
|aws_dms_s3_endpoint_invalid_compression_type|✔|
|aws_dms_s3_endpoint_invalid_data_format|✔|
|aws_dms_s3_endpoint_invalid_date_partition_delimiter|✔|
|aws_dms_s3_endpoint_invalid_date_partition_sequence|✔|
|aws_dms_s3_endpoint_invalid_encoding_type|✔|
|aws_dms_s3_endpoint_invalid_encryption_mode|✔|
|aws_dms_s3_endpoint_invalid_parquet_version|✔|
|aws_docdb_global_cluster_invalid_global_cluster_identifier|✔|
|aws_dx_bgp_peer_invalid_address_family|✔|
|aws_dx_hosted_private_virtual_interface_invalid_address_family|✔|
Expand Down Expand Up @@ -586,7 +594,6 @@ These rules enforce best practices and naming conventions:
|aws_efs_mount_target_invalid_ip_address|✔|
|aws_efs_mount_target_invalid_subnet_id|✔|
|aws_eks_addon_invalid_cluster_name|✔|
|aws_eks_addon_invalid_resolve_conflicts|✔|
|aws_eks_addon_invalid_service_account_role_arn|✔|
|aws_eks_cluster_invalid_name|✔|
|aws_eks_node_group_invalid_ami_type|✔|
Expand Down Expand Up @@ -930,11 +937,6 @@ These rules enforce best practices and naming conventions:
|aws_networkfirewall_rule_group_invalid_name|✔|
|aws_networkfirewall_rule_group_invalid_rules|✔|
|aws_networkfirewall_rule_group_invalid_type|✔|
|aws_opsworks_application_invalid_type|✔|
|aws_opsworks_instance_invalid_architecture|✔|
|aws_opsworks_instance_invalid_auto_scaling_type|✔|
|aws_opsworks_instance_invalid_root_device_type|✔|
|aws_opsworks_stack_invalid_default_root_device_type|✔|
|aws_organizations_account_invalid_email|✔|
|aws_organizations_account_invalid_iam_user_access_to_billing|✔|
|aws_organizations_account_invalid_name|✔|
Expand Down Expand Up @@ -1260,7 +1262,6 @@ These rules enforce best practices and naming conventions:
|aws_ssm_association_invalid_association_name|✔|
|aws_ssm_association_invalid_compliance_severity|✔|
|aws_ssm_association_invalid_document_version|✔|
|aws_ssm_association_invalid_instance_id|✔|
|aws_ssm_association_invalid_max_concurrency|✔|
|aws_ssm_association_invalid_max_errors|✔|
|aws_ssm_association_invalid_name|✔|
Expand Down
101 changes: 101 additions & 0 deletions rules/models/aws_dms_s3_endpoint_invalid_canned_acl_for_objects.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsDmsS3EndpointInvalidCannedACLForObjectsRule checks the pattern is valid
type AwsDmsS3EndpointInvalidCannedACLForObjectsRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
}

// NewAwsDmsS3EndpointInvalidCannedACLForObjectsRule returns new rule with default attributes
func NewAwsDmsS3EndpointInvalidCannedACLForObjectsRule() *AwsDmsS3EndpointInvalidCannedACLForObjectsRule {
return &AwsDmsS3EndpointInvalidCannedACLForObjectsRule{
resourceType: "aws_dms_s3_endpoint",
attributeName: "canned_acl_for_objects",
enum: []string{
"none",
"private",
"public-read",
"public-read-write",
"authenticated-read",
"aws-exec-read",
"bucket-owner-read",
"bucket-owner-full-control",
},
}
}

// Name returns the rule name
func (r *AwsDmsS3EndpointInvalidCannedACLForObjectsRule) Name() string {
return "aws_dms_s3_endpoint_invalid_canned_acl_for_objects"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsDmsS3EndpointInvalidCannedACLForObjectsRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsDmsS3EndpointInvalidCannedACLForObjectsRule) Severity() tflint.Severity {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsDmsS3EndpointInvalidCannedACLForObjectsRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsDmsS3EndpointInvalidCannedACLForObjectsRule) Check(runner tflint.Runner) error {
logger.Trace("Check `%s` rule", r.Name())

resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func (val string) error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as canned_acl_for_objects`, truncateLongMessage(val)),
attribute.Expr.Range(),
)
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
95 changes: 95 additions & 0 deletions rules/models/aws_dms_s3_endpoint_invalid_compression_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsDmsS3EndpointInvalidCompressionTypeRule checks the pattern is valid
type AwsDmsS3EndpointInvalidCompressionTypeRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
}

// NewAwsDmsS3EndpointInvalidCompressionTypeRule returns new rule with default attributes
func NewAwsDmsS3EndpointInvalidCompressionTypeRule() *AwsDmsS3EndpointInvalidCompressionTypeRule {
return &AwsDmsS3EndpointInvalidCompressionTypeRule{
resourceType: "aws_dms_s3_endpoint",
attributeName: "compression_type",
enum: []string{
"none",
"gzip",
},
}
}

// Name returns the rule name
func (r *AwsDmsS3EndpointInvalidCompressionTypeRule) Name() string {
return "aws_dms_s3_endpoint_invalid_compression_type"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsDmsS3EndpointInvalidCompressionTypeRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsDmsS3EndpointInvalidCompressionTypeRule) Severity() tflint.Severity {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsDmsS3EndpointInvalidCompressionTypeRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsDmsS3EndpointInvalidCompressionTypeRule) Check(runner tflint.Runner) error {
logger.Trace("Check `%s` rule", r.Name())

resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func (val string) error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as compression_type`, truncateLongMessage(val)),
attribute.Expr.Range(),
)
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
95 changes: 95 additions & 0 deletions rules/models/aws_dms_s3_endpoint_invalid_data_format.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// This file generated by `generator/`. DO NOT EDIT

package models

import (
"fmt"

"github.com/terraform-linters/tflint-plugin-sdk/hclext"
"github.com/terraform-linters/tflint-plugin-sdk/logger"
"github.com/terraform-linters/tflint-plugin-sdk/tflint"
)

// AwsDmsS3EndpointInvalidDataFormatRule checks the pattern is valid
type AwsDmsS3EndpointInvalidDataFormatRule struct {
tflint.DefaultRule

resourceType string
attributeName string
enum []string
}

// NewAwsDmsS3EndpointInvalidDataFormatRule returns new rule with default attributes
func NewAwsDmsS3EndpointInvalidDataFormatRule() *AwsDmsS3EndpointInvalidDataFormatRule {
return &AwsDmsS3EndpointInvalidDataFormatRule{
resourceType: "aws_dms_s3_endpoint",
attributeName: "data_format",
enum: []string{
"csv",
"parquet",
},
}
}

// Name returns the rule name
func (r *AwsDmsS3EndpointInvalidDataFormatRule) Name() string {
return "aws_dms_s3_endpoint_invalid_data_format"
}

// Enabled returns whether the rule is enabled by default
func (r *AwsDmsS3EndpointInvalidDataFormatRule) Enabled() bool {
return true
}

// Severity returns the rule severity
func (r *AwsDmsS3EndpointInvalidDataFormatRule) Severity() tflint.Severity {
return tflint.ERROR
}

// Link returns the rule reference link
func (r *AwsDmsS3EndpointInvalidDataFormatRule) Link() string {
return ""
}

// Check checks the pattern is valid
func (r *AwsDmsS3EndpointInvalidDataFormatRule) Check(runner tflint.Runner) error {
logger.Trace("Check `%s` rule", r.Name())

resources, err := runner.GetResourceContent(r.resourceType, &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{
{Name: r.attributeName},
},
}, nil)
if err != nil {
return err
}

for _, resource := range resources.Blocks {
attribute, exists := resource.Body.Attributes[r.attributeName]
if !exists {
continue
}

err := runner.EvaluateExpr(attribute.Expr, func (val string) error {
found := false
for _, item := range r.enum {
if item == val {
found = true
}
}
if !found {
runner.EmitIssue(
r,
fmt.Sprintf(`"%s" is an invalid value as data_format`, truncateLongMessage(val)),
attribute.Expr.Range(),
)
}
return nil
}, nil)
if err != nil {
return err
}
}

return nil
}
Loading