Skip to content
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

resource/aws_s3_bucket: Remove automatic aws_s3_bucket_policy import #14121

Merged
merged 2 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
40 changes: 0 additions & 40 deletions aws/import_aws_s3_bucket.go

This file was deleted.

2 changes: 1 addition & 1 deletion aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func resourceAwsS3Bucket() *schema.Resource {
Update: resourceAwsS3BucketUpdate,
Delete: resourceAwsS3BucketDelete,
Importer: &schema.ResourceImporter{
State: resourceAwsS3BucketImportState,
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
Expand Down
35 changes: 14 additions & 21 deletions aws/resource_aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,24 +531,6 @@ func TestAccAWSS3Bucket_Policy(t *testing.T) {
partition := testAccGetPartition()
resourceName := "aws_s3_bucket.bucket"

checkFn := func(s []*terraform.InstanceState) error {
// Expect 2: bucket + policy
if len(s) != 2 {
return fmt.Errorf("expected 2 states: %#v", s)
}
bucketState, policyState := s[0], s[1]

if bucketState.ID != bucketName {
return fmt.Errorf("expected bucket of ID %s, %s received", bucketName, bucketState.ID)
}

if policyState.ID != bucketName {
return fmt.Errorf("expected policy of ID %s, %s received", bucketName, bucketState.ID)
}

return nil
}

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -562,9 +544,20 @@ func TestAccAWSS3Bucket_Policy(t *testing.T) {
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateCheck: checkFn,
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"acl",
"force_destroy",
"grant",
// NOTE: Prior to Terraform AWS Provider 3.0, this attribute did not import correctly either.
// The Read function does not require GetBucketPolicy, if the argument is not configured.
// Rather than introduce that breaking change as well with 3.0, instead we leave the
// current Read behavior and note this will be deprecated in a later 3.x release along
// with other inline policy attributes across the provider.
"policy",
},
},
{
Config: testAccAWSS3BucketConfig_Basic(bucketName),
Expand Down
7 changes: 7 additions & 0 deletions website/docs/guides/version-3-upgrade.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Upgrade topics:
- [Data Source: aws_availability_zones](#data-source-aws_availability_zones)
- [Data Source: aws_lambda_invocation](#data-source-aws_lambda_invocation)
- [Resource: aws_emr_cluster](#resource-aws_emr_cluster)
- [Resource: aws_s3_bucket](#resource-aws_s3_bucket)

<!-- /TOC -->

Expand Down Expand Up @@ -287,3 +288,9 @@ resource "aws_lb_listener_rule" "example" {
}
}
```

## Resource: aws_s3_bucket

### Removal of Automatic aws_s3_bucket_policy Import

Previously when importing the `aws_s3_bucket` resource with the [`terraform import` command](/docs/commands/import.html), the Terraform AWS Provider would automatically attempt to import an associated `aws_s3_bucket_policy` resource as well. This automatic resource import has been removed. Use the [`aws_s3_bucket_policy` resource import](/docs/providers/aws/r/s3_bucket_policy.html#import) to import that resource separately.
2 changes: 2 additions & 0 deletions website/docs/r/s3_bucket.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -533,3 +533,5 @@ S3 bucket can be imported using the `bucket`, e.g.
```
$ terraform import aws_s3_bucket.bucket bucket-name
```

The `policy` argument is not imported and will be deprecated in a future version 3.x of the Terraform AWS Provider for removal in version 4.0. Use the [`aws_s3_bucket_policy` resource](/docs/providers/aws/r/s3_bucket_policy.html) to manage the S3 Bucket Policy instead.