From e6489e61a37b1b27bcc1566e33b9ffb34f25b362 Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 10 Mar 2020 15:18:44 -0500 Subject: [PATCH] provider: Fix and enable tfproviderlint S031, S032, and S033 (#12234) Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/12087 Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/11869 (fix and enable S031) Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/11870 (fix and enable S032) Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/11871 (fix and enable S033) Previously: ``` aws/data_source_aws_cloudhsm2_cluster.go:38:28: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_dynamodb_table.go:149:11: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_dynamodb_table.go:192:30: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_efs_file_system.go:62:24: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_eks_cluster.go:23:29: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_eks_cluster.go:89:18: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_elastic_beanstalk_application.go:29:28: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_elb.go:27:19: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_elb.go:80:20: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_function.go:130:19: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_function.go:144:22: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_function.go:31:26: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_function.go:49:14: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_function.go:81:18: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_layer_version.go:34:27: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lb.go:74:19: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lb_target_group.go:73:18: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lb_target_group.go:95:20: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_mq_broker.go:131:37: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_mq_broker.go:37:21: S031: schema should not only enable Computed and configure MaxItems aws/resource_aws_api_gateway_account.go:29:25: S031: schema should not only enable Computed and configure MaxItems aws/resource_aws_cloudhsm2_cluster.go:64:28: S031: schema should not only enable Computed and configure MaxItems aws/resource_aws_eks_cluster.go:47:29: S031: schema should not only enable Computed and configure MaxItems aws/data_source_aws_lambda_function.go:31:26: S032: schema should not only enable Computed and configure MinItems aws/data_source_aws_cloudformation_stack.go:22:21: S033: schema should not only enable Computed and configure StateFunc aws/data_source_aws_dynamodb_table.go:140:24: S033: schema should not only enable Computed and configure StateFunc aws/data_source_aws_rds_cluster.go:120:36: S033: schema should not only enable Computed and configure StateFunc ``` Output from acceptance testing: ``` --- PASS: TestAccAWSAPIGatewayAccount_basic (116.01s) --- PASS: TestAccAWSCloudFormationStack_dataSource_basic (74.98s) --- PASS: TestAccAWSCloudFormationStack_dataSource_yaml (74.96s) --- PASS: TestAccAWSCloudHsm2Cluster_basic (292.57s) --- PASS: TestAccAWSCloudHsm2Cluster_Tags (340.49s) --- PASS: TestAccAWSEksCluster_basic (1204.53s) --- PASS: TestAccAWSEksCluster_Logging (1300.14s) --- PASS: TestAccAWSEksCluster_Tags (1280.00s) --- PASS: TestAccAWSEksCluster_Version (2452.84s) --- PASS: TestAccAWSEksCluster_VpcConfig_EndpointPrivateAccess (2435.44s) --- PASS: TestAccAWSEksCluster_VpcConfig_EndpointPublicAccess (1720.71s) --- PASS: TestAccAWSEksCluster_VpcConfig_PublicAccessCidrs (1587.49s) --- PASS: TestAccAWSEksCluster_VpcConfig_SecurityGroupIds (1186.78s) --- PASS: TestAccAWSEksClusterDataSource_basic (1239.69s) --- PASS: TestAccAwsElasticBeanstalkApplicationDataSource_basic (21.56s) --- PASS: TestAccDataSourceAWSALBTargetGroup_basic (175.08s) --- PASS: TestAccDataSourceAwsDynamoDbTable_basic (44.81s) --- PASS: TestAccDataSourceAwsEfsFileSystem_id (29.06s) --- PASS: TestAccDataSourceAwsEfsFileSystem_name (28.39s) --- PASS: TestAccDataSourceAWSELB_basic (53.87s) --- PASS: TestAccDataSourceAWSLambdaFunction_alias (65.51s) --- PASS: TestAccDataSourceAWSLambdaFunction_basic (49.09s) --- PASS: TestAccDataSourceAWSLambdaFunction_environment (59.75s) --- PASS: TestAccDataSourceAWSLambdaFunction_layers (71.91s) --- PASS: TestAccDataSourceAWSLambdaFunction_version (41.88s) --- PASS: TestAccDataSourceAWSLambdaFunction_vpc (1838.06s) --- PASS: TestAccDataSourceAWSLambdaLayerVersion_basic (19.83s) --- PASS: TestAccDataSourceAWSLambdaLayerVersion_runtime (46.22s) --- PASS: TestAccDataSourceAWSLambdaLayerVersion_version (35.61s) --- PASS: TestAccDataSourceAWSLB_basic (211.76s) --- PASS: TestAccDataSourceAWSMqBroker_basic (1232.73s) --- PASS: TestAccDataSourceAWSRDSCluster_basic (135.85s) --- PASS: TestAccDataSourceCloudHsm2Cluster_basic (267.05s) ``` --- GNUmakefile | 3 +++ aws/data_source_aws_cloudformation_stack.go | 4 ---- aws/data_source_aws_cloudhsm2_cluster.go | 1 - aws/data_source_aws_dynamodb_table.go | 7 ------- aws/data_source_aws_efs_file_system.go | 1 - aws/data_source_aws_eks_cluster.go | 2 -- aws/data_source_aws_elastic_beanstalk_application.go | 1 - aws/data_source_aws_elb.go | 2 -- aws/data_source_aws_lambda_function.go | 6 ------ aws/data_source_aws_lambda_layer_version.go | 1 - aws/data_source_aws_lb.go | 1 - aws/data_source_aws_lb_target_group.go | 2 -- aws/data_source_aws_mq_broker.go | 2 -- aws/data_source_aws_rds_cluster.go | 7 ------- aws/resource_aws_api_gateway_account.go | 1 - aws/resource_aws_cloudhsm2_cluster.go | 1 - aws/resource_aws_eks_cluster.go | 1 - 17 files changed, 3 insertions(+), 40 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index c682fc3f1b4..772bb67de67 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -98,6 +98,9 @@ lint: -S028 \ -S029 \ -S030 \ + -S031 \ + -S032 \ + -S033 \ -S034 \ -V003 \ -V006 \ diff --git a/aws/data_source_aws_cloudformation_stack.go b/aws/data_source_aws_cloudformation_stack.go index 1b1e440c6cd..d1182ef49e9 100644 --- a/aws/data_source_aws_cloudformation_stack.go +++ b/aws/data_source_aws_cloudformation_stack.go @@ -22,10 +22,6 @@ func dataSourceAwsCloudFormationStack() *schema.Resource { "template_body": { Type: schema.TypeString, Computed: true, - StateFunc: func(v interface{}) string { - template, _ := normalizeCloudFormationTemplate(v) - return template - }, }, "capabilities": { Type: schema.TypeSet, diff --git a/aws/data_source_aws_cloudhsm2_cluster.go b/aws/data_source_aws_cloudhsm2_cluster.go index 97e27731724..1de17a0c80e 100644 --- a/aws/data_source_aws_cloudhsm2_cluster.go +++ b/aws/data_source_aws_cloudhsm2_cluster.go @@ -37,7 +37,6 @@ func dataSourceCloudHsm2Cluster() *schema.Resource { "cluster_certificates": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/data_source_aws_dynamodb_table.go b/aws/data_source_aws_dynamodb_table.go index 2bd4d3dcb51..77594acee11 100644 --- a/aws/data_source_aws_dynamodb_table.go +++ b/aws/data_source_aws_dynamodb_table.go @@ -3,7 +3,6 @@ package aws import ( "bytes" "fmt" - "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/dynamodb" @@ -140,16 +139,11 @@ func dataSourceAwsDynamoDbTable() *schema.Resource { "stream_view_type": { Type: schema.TypeString, Computed: true, - StateFunc: func(v interface{}) string { - value := v.(string) - return strings.ToUpper(value) - }, }, "tags": tagsSchemaComputed(), "ttl": { Type: schema.TypeSet, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "attribute_name": { @@ -192,7 +186,6 @@ func dataSourceAwsDynamoDbTable() *schema.Resource { "point_in_time_recovery": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { diff --git a/aws/data_source_aws_efs_file_system.go b/aws/data_source_aws_efs_file_system.go index 008e88edc9b..cbe4ac0f554 100644 --- a/aws/data_source_aws_efs_file_system.go +++ b/aws/data_source_aws_efs_file_system.go @@ -62,7 +62,6 @@ func dataSourceAwsEfsFileSystem() *schema.Resource { "lifecycle_policy": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "transition_to_ia": { diff --git a/aws/data_source_aws_eks_cluster.go b/aws/data_source_aws_eks_cluster.go index b289ee01f63..f6decfa3c5d 100644 --- a/aws/data_source_aws_eks_cluster.go +++ b/aws/data_source_aws_eks_cluster.go @@ -22,7 +22,6 @@ func dataSourceAwsEksCluster() *schema.Resource { }, "certificate_authority": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -88,7 +87,6 @@ func dataSourceAwsEksCluster() *schema.Resource { "tags": tagsSchemaComputed(), "vpc_config": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/data_source_aws_elastic_beanstalk_application.go b/aws/data_source_aws_elastic_beanstalk_application.go index 400dc7f6e0e..c1d0a7d3ed8 100644 --- a/aws/data_source_aws_elastic_beanstalk_application.go +++ b/aws/data_source_aws_elastic_beanstalk_application.go @@ -29,7 +29,6 @@ func dataSourceAwsElasticBeanstalkApplication() *schema.Resource { "appversion_lifecycle": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "service_role": { diff --git a/aws/data_source_aws_elb.go b/aws/data_source_aws_elb.go index b81d48f902b..b4d40db9728 100644 --- a/aws/data_source_aws_elb.go +++ b/aws/data_source_aws_elb.go @@ -27,7 +27,6 @@ func dataSourceAwsElb() *schema.Resource { "access_logs": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "interval": { @@ -80,7 +79,6 @@ func dataSourceAwsElb() *schema.Resource { "health_check": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "healthy_threshold": { diff --git a/aws/data_source_aws_lambda_function.go b/aws/data_source_aws_lambda_function.go index 1a72e0d23d9..3c4a3f5e92f 100644 --- a/aws/data_source_aws_lambda_function.go +++ b/aws/data_source_aws_lambda_function.go @@ -31,8 +31,6 @@ func dataSourceAwsLambdaFunction() *schema.Resource { "dead_letter_config": { Type: schema.TypeList, Computed: true, - MinItems: 0, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "target_arn": { @@ -49,7 +47,6 @@ func dataSourceAwsLambdaFunction() *schema.Resource { "layers": { Type: schema.TypeList, Computed: true, - MaxItems: 5, Elem: &schema.Schema{ Type: schema.TypeString, }, @@ -81,7 +78,6 @@ func dataSourceAwsLambdaFunction() *schema.Resource { "vpc_config": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "subnet_ids": { @@ -130,7 +126,6 @@ func dataSourceAwsLambdaFunction() *schema.Resource { "environment": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "variables": { @@ -143,7 +138,6 @@ func dataSourceAwsLambdaFunction() *schema.Resource { }, "tracing_config": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/data_source_aws_lambda_layer_version.go b/aws/data_source_aws_lambda_layer_version.go index 58562574818..30e9167feac 100644 --- a/aws/data_source_aws_lambda_layer_version.go +++ b/aws/data_source_aws_lambda_layer_version.go @@ -34,7 +34,6 @@ func dataSourceAwsLambdaLayerVersion() *schema.Resource { "compatible_runtimes": { Type: schema.TypeSet, Computed: true, - MaxItems: 5, Elem: &schema.Schema{ Type: schema.TypeString, }, diff --git a/aws/data_source_aws_lb.go b/aws/data_source_aws_lb.go index b827dc3eab0..f09e2205c87 100644 --- a/aws/data_source_aws_lb.go +++ b/aws/data_source_aws_lb.go @@ -74,7 +74,6 @@ func dataSourceAwsLb() *schema.Resource { "access_logs": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "bucket": { diff --git a/aws/data_source_aws_lb_target_group.go b/aws/data_source_aws_lb_target_group.go index cff2cf93999..a9f241bd08e 100644 --- a/aws/data_source_aws_lb_target_group.go +++ b/aws/data_source_aws_lb_target_group.go @@ -73,7 +73,6 @@ func dataSourceAwsLbTargetGroup() *schema.Resource { "stickiness": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { @@ -95,7 +94,6 @@ func dataSourceAwsLbTargetGroup() *schema.Resource { "health_check": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "enabled": { diff --git a/aws/data_source_aws_mq_broker.go b/aws/data_source_aws_mq_broker.go index a7e00f8c713..af80a8403d8 100644 --- a/aws/data_source_aws_mq_broker.go +++ b/aws/data_source_aws_mq_broker.go @@ -37,7 +37,6 @@ func dataSourceAwsMqBroker() *schema.Resource { "configuration": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "id": { @@ -130,7 +129,6 @@ func dataSourceAwsMqBroker() *schema.Resource { }, "maintenance_window_start_time": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/data_source_aws_rds_cluster.go b/aws/data_source_aws_rds_cluster.go index 00427b42213..7a111a2f57c 100644 --- a/aws/data_source_aws_rds_cluster.go +++ b/aws/data_source_aws_rds_cluster.go @@ -3,7 +3,6 @@ package aws import ( "fmt" "log" - "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/rds" @@ -120,12 +119,6 @@ func dataSourceAwsRdsCluster() *schema.Resource { "preferred_maintenance_window": { Type: schema.TypeString, Computed: true, - StateFunc: func(val interface{}) string { - if val == nil { - return "" - } - return strings.ToLower(val.(string)) - }, }, "port": { diff --git a/aws/resource_aws_api_gateway_account.go b/aws/resource_aws_api_gateway_account.go index a7587d710c8..c48c9bcd7ea 100644 --- a/aws/resource_aws_api_gateway_account.go +++ b/aws/resource_aws_api_gateway_account.go @@ -29,7 +29,6 @@ func resourceAwsApiGatewayAccount() *schema.Resource { "throttle_settings": { Type: schema.TypeList, Computed: true, - MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "burst_limit": { diff --git a/aws/resource_aws_cloudhsm2_cluster.go b/aws/resource_aws_cloudhsm2_cluster.go index 65dda087432..a59255804bd 100644 --- a/aws/resource_aws_cloudhsm2_cluster.go +++ b/aws/resource_aws_cloudhsm2_cluster.go @@ -63,7 +63,6 @@ func resourceAwsCloudHsm2Cluster() *schema.Resource { "cluster_certificates": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ diff --git a/aws/resource_aws_eks_cluster.go b/aws/resource_aws_eks_cluster.go index c1d55c2169d..d9d71d4cbc6 100644 --- a/aws/resource_aws_eks_cluster.go +++ b/aws/resource_aws_eks_cluster.go @@ -46,7 +46,6 @@ func resourceAwsEksCluster() *schema.Resource { }, "certificate_authority": { Type: schema.TypeList, - MaxItems: 1, Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{