diff --git a/docs/rules/README.md b/docs/rules/README.md index 4275a932..d474d270 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -1177,14 +1177,11 @@ These rules enforce best practices and naming conventions: |aws_securityhub_standards_control_invalid_standards_control_arn|✔| |aws_securityhub_standards_subscription_invalid_standards_arn|✔| |aws_service_discovery_http_namespace_invalid_description|✔| -|aws_service_discovery_http_namespace_invalid_name|✔| |aws_service_discovery_instance_invalid_instance_id|✔| |aws_service_discovery_instance_invalid_service_id|✔| |aws_service_discovery_private_dns_namespace_invalid_description|✔| -|aws_service_discovery_private_dns_namespace_invalid_name|✔| |aws_service_discovery_private_dns_namespace_invalid_vpc|✔| |aws_service_discovery_public_dns_namespace_invalid_description|✔| -|aws_service_discovery_public_dns_namespace_invalid_name|✔| |aws_service_discovery_service_invalid_description|✔| |aws_servicecatalog_budget_resource_association_invalid_budget_name|✔| |aws_servicecatalog_budget_resource_association_invalid_resource_id|✔| diff --git a/rules/models/aws_service_discovery_http_namespace_invalid_name.go b/rules/models/aws_service_discovery_http_namespace_invalid_name.go deleted file mode 100644 index 9e5fb003..00000000 --- a/rules/models/aws_service_discovery_http_namespace_invalid_name.go +++ /dev/null @@ -1,84 +0,0 @@ -// This file generated by `generator/`. DO NOT EDIT - -package models - -import ( - "github.com/terraform-linters/tflint-plugin-sdk/hclext" - "github.com/terraform-linters/tflint-plugin-sdk/logger" - "github.com/terraform-linters/tflint-plugin-sdk/tflint" -) - -// AwsServiceDiscoveryHTTPNamespaceInvalidNameRule checks the pattern is valid -type AwsServiceDiscoveryHTTPNamespaceInvalidNameRule struct { - tflint.DefaultRule - - resourceType string - attributeName string - max int -} - -// NewAwsServiceDiscoveryHTTPNamespaceInvalidNameRule returns new rule with default attributes -func NewAwsServiceDiscoveryHTTPNamespaceInvalidNameRule() *AwsServiceDiscoveryHTTPNamespaceInvalidNameRule { - return &AwsServiceDiscoveryHTTPNamespaceInvalidNameRule{ - resourceType: "aws_service_discovery_http_namespace", - attributeName: "name", - max: 1024, - } -} - -// Name returns the rule name -func (r *AwsServiceDiscoveryHTTPNamespaceInvalidNameRule) Name() string { - return "aws_service_discovery_http_namespace_invalid_name" -} - -// Enabled returns whether the rule is enabled by default -func (r *AwsServiceDiscoveryHTTPNamespaceInvalidNameRule) Enabled() bool { - return true -} - -// Severity returns the rule severity -func (r *AwsServiceDiscoveryHTTPNamespaceInvalidNameRule) Severity() tflint.Severity { - return tflint.ERROR -} - -// Link returns the rule reference link -func (r *AwsServiceDiscoveryHTTPNamespaceInvalidNameRule) Link() string { - return "" -} - -// Check checks the pattern is valid -func (r *AwsServiceDiscoveryHTTPNamespaceInvalidNameRule) 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 { - if len(val) > r.max { - runner.EmitIssue( - r, - "name must be 1024 characters or less", - attribute.Expr.Range(), - ) - } - return nil - }, nil) - if err != nil { - return err - } - } - - return nil -} diff --git a/rules/models/aws_service_discovery_private_dns_namespace_invalid_name.go b/rules/models/aws_service_discovery_private_dns_namespace_invalid_name.go deleted file mode 100644 index 21e19166..00000000 --- a/rules/models/aws_service_discovery_private_dns_namespace_invalid_name.go +++ /dev/null @@ -1,84 +0,0 @@ -// This file generated by `generator/`. DO NOT EDIT - -package models - -import ( - "github.com/terraform-linters/tflint-plugin-sdk/hclext" - "github.com/terraform-linters/tflint-plugin-sdk/logger" - "github.com/terraform-linters/tflint-plugin-sdk/tflint" -) - -// AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule checks the pattern is valid -type AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule struct { - tflint.DefaultRule - - resourceType string - attributeName string - max int -} - -// NewAwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule returns new rule with default attributes -func NewAwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule() *AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule { - return &AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule{ - resourceType: "aws_service_discovery_private_dns_namespace", - attributeName: "name", - max: 1024, - } -} - -// Name returns the rule name -func (r *AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule) Name() string { - return "aws_service_discovery_private_dns_namespace_invalid_name" -} - -// Enabled returns whether the rule is enabled by default -func (r *AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule) Enabled() bool { - return true -} - -// Severity returns the rule severity -func (r *AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule) Severity() tflint.Severity { - return tflint.ERROR -} - -// Link returns the rule reference link -func (r *AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule) Link() string { - return "" -} - -// Check checks the pattern is valid -func (r *AwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule) 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 { - if len(val) > r.max { - runner.EmitIssue( - r, - "name must be 1024 characters or less", - attribute.Expr.Range(), - ) - } - return nil - }, nil) - if err != nil { - return err - } - } - - return nil -} diff --git a/rules/models/aws_service_discovery_public_dns_namespace_invalid_name.go b/rules/models/aws_service_discovery_public_dns_namespace_invalid_name.go deleted file mode 100644 index 7bc62aa9..00000000 --- a/rules/models/aws_service_discovery_public_dns_namespace_invalid_name.go +++ /dev/null @@ -1,84 +0,0 @@ -// This file generated by `generator/`. DO NOT EDIT - -package models - -import ( - "github.com/terraform-linters/tflint-plugin-sdk/hclext" - "github.com/terraform-linters/tflint-plugin-sdk/logger" - "github.com/terraform-linters/tflint-plugin-sdk/tflint" -) - -// AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule checks the pattern is valid -type AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule struct { - tflint.DefaultRule - - resourceType string - attributeName string - max int -} - -// NewAwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule returns new rule with default attributes -func NewAwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule() *AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule { - return &AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule{ - resourceType: "aws_service_discovery_public_dns_namespace", - attributeName: "name", - max: 1024, - } -} - -// Name returns the rule name -func (r *AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule) Name() string { - return "aws_service_discovery_public_dns_namespace_invalid_name" -} - -// Enabled returns whether the rule is enabled by default -func (r *AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule) Enabled() bool { - return true -} - -// Severity returns the rule severity -func (r *AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule) Severity() tflint.Severity { - return tflint.ERROR -} - -// Link returns the rule reference link -func (r *AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule) Link() string { - return "" -} - -// Check checks the pattern is valid -func (r *AwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule) 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 { - if len(val) > r.max { - runner.EmitIssue( - r, - "name must be 1024 characters or less", - attribute.Expr.Range(), - ) - } - return nil - }, nil) - if err != nil { - return err - } - } - - return nil -} diff --git a/rules/models/mappings/service-discovery.hcl b/rules/models/mappings/service-discovery.hcl index 79b6f427..0be18c43 100644 --- a/rules/models/mappings/service-discovery.hcl +++ b/rules/models/mappings/service-discovery.hcl @@ -1,7 +1,7 @@ import = "aws-sdk-ruby/apis/servicediscovery/2017-03-14/api-2.json" mapping "aws_service_discovery_http_namespace" { - name = NamespaceName + name = any //NamespaceName description = ResourceDescription } @@ -12,13 +12,13 @@ mapping "aws_service_discovery_instance" { } mapping "aws_service_discovery_private_dns_namespace" { - name = NamespaceName + name = any //NamespaceName vpc = ResourceId description = ResourceDescription } mapping "aws_service_discovery_public_dns_namespace" { - name = NamespaceName + name = any //NamespaceName description = ResourceDescription } diff --git a/rules/models/provider.go b/rules/models/provider.go index d7717e54..e4381700 100644 --- a/rules/models/provider.go +++ b/rules/models/provider.go @@ -1099,14 +1099,11 @@ var Rules = []tflint.Rule{ NewAwsSecurityhubStandardsControlInvalidStandardsControlArnRule(), NewAwsSecurityhubStandardsSubscriptionInvalidStandardsArnRule(), NewAwsServiceDiscoveryHTTPNamespaceInvalidDescriptionRule(), - NewAwsServiceDiscoveryHTTPNamespaceInvalidNameRule(), NewAwsServiceDiscoveryInstanceInvalidInstanceIDRule(), NewAwsServiceDiscoveryInstanceInvalidServiceIDRule(), NewAwsServiceDiscoveryPrivateDNSNamespaceInvalidDescriptionRule(), - NewAwsServiceDiscoveryPrivateDNSNamespaceInvalidNameRule(), NewAwsServiceDiscoveryPrivateDNSNamespaceInvalidVpcRule(), NewAwsServiceDiscoveryPublicDNSNamespaceInvalidDescriptionRule(), - NewAwsServiceDiscoveryPublicDNSNamespaceInvalidNameRule(), NewAwsServiceDiscoveryServiceInvalidDescriptionRule(), NewAwsServicecatalogBudgetResourceAssociationInvalidBudgetNameRule(), NewAwsServicecatalogBudgetResourceAssociationInvalidResourceIDRule(),