Skip to content

Commit

Permalink
tests/provider: Enable tfproviderlint R004 check (#11499)
Browse files Browse the repository at this point in the history
* tests/provider: Enable tfproviderlint R004 check

Reference: https://github.com/bflad/tfproviderlint/blob/master/passes/R004/README.md
Reference: #9954

* 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)
```
  • Loading branch information
bflad authored Feb 5, 2020
1 parent 09c565f commit 82b8834
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ lint:
-AT002 \
-AT006 \
-AT007 \
-R004 \
-S001 \
-S002 \
-S003 \
Expand Down
2 changes: 1 addition & 1 deletion aws/import_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 82b8834

Please sign in to comment.