From 75de0eb8e0c34615b0db283c18eda1c18805c59e Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Mon, 6 Jan 2020 15:22:57 -0500 Subject: [PATCH 1/2] tests/provider: Enable tfproviderlint R004 check Reference: https://github.com/bflad/tfproviderlint/blob/master/passes/R004/README.md Reference: https://github.com/terraform-providers/terraform-provider-aws/issues/9954 --- GNUmakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/GNUmakefile b/GNUmakefile index 0d3322de58c..7763fe6ad4f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -58,6 +58,7 @@ lint: -AT002 \ -AT006 \ -AT007 \ + -R004 \ -S001 \ -S002 \ -S003 \ From f417c824da51a07c156d7d0751f46d719e761ccb Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Tue, 4 Feb 2020 20:45:14 -0500 Subject: [PATCH 2/2] resource/aws_s3_bucket: Fix complex import of aws_s3_bucket_policy to properly set policy in state Found via linting: ``` /Users/bflad/src/github.com/terraform-providers/terraform-provider-aws/aws/import_aws_s3_bucket.go:36:22: R004: ResourceData.Set() incompatible value type: *github.com/aws/aws-sdk-go/service/s3.GetBucketPolicyOutput 35 pData.Set("bucket", d.Id()) 36 pData.Set("policy", pol) 37 results = append(results, pData) ``` This type of complex import (importing multiple resources) is likely to be removed in a future major version. Output from relevant acceptance testing (other tests do not perform necessary ImportStateCheck to verify complex import): ``` --- PASS: TestAccAWSS3Bucket_Policy (95.74s) ``` --- aws/import_aws_s3_bucket.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/import_aws_s3_bucket.go b/aws/import_aws_s3_bucket.go index b1702011218..987bb180d14 100644 --- a/aws/import_aws_s3_bucket.go +++ b/aws/import_aws_s3_bucket.go @@ -33,7 +33,7 @@ func resourceAwsS3BucketImportState( pData.SetId(d.Id()) pData.SetType("aws_s3_bucket_policy") pData.Set("bucket", d.Id()) - pData.Set("policy", pol) + pData.Set("policy", pol.Policy) results = append(results, pData) return results, nil