Skip to content

Commit

Permalink
resource/aws_s3_bucket: Remove automatic aws_s3_bucket_policy import (#…
Browse files Browse the repository at this point in the history
…14121)

Reference: #394
Reference: #9001
Reference: #9508
Reference: #12805

Output from acceptance testing:

```
--- PASS: TestAccAWSS3Bucket_acceleration (70.53s)
--- PASS: TestAccAWSS3Bucket_AclToGrant (64.37s)
--- PASS: TestAccAWSS3Bucket_basic (37.90s)
--- PASS: TestAccAWSS3Bucket_Bucket_EmptyString (39.08s)
--- PASS: TestAccAWSS3Bucket_Cors_Delete (32.28s)
--- PASS: TestAccAWSS3Bucket_Cors_EmptyOrigin (39.25s)
--- PASS: TestAccAWSS3Bucket_Cors_Update (68.80s)
--- PASS: TestAccAWSS3Bucket_disableDefaultEncryption_whenDefaultEncryptionIsEnabled (67.23s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenAES256IsUsed (37.19s)
--- PASS: TestAccAWSS3Bucket_enableDefaultEncryption_whenTypical (44.32s)
--- PASS: TestAccAWSS3Bucket_forceDestroy (37.21s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithEmptyPrefixes (38.50s)
--- PASS: TestAccAWSS3Bucket_forceDestroyWithObjectLockEnabled (37.77s)
--- PASS: TestAccAWSS3Bucket_generatedName (38.80s)
--- PASS: TestAccAWSS3Bucket_GrantToAcl (60.31s)
--- PASS: TestAccAWSS3Bucket_LifecycleBasic (89.67s)
--- PASS: TestAccAWSS3Bucket_LifecycleExpireMarkerOnly (67.52s)
--- PASS: TestAccAWSS3Bucket_LifecycleRule_Expiration_EmptyConfigurationBlock (30.08s)
--- PASS: TestAccAWSS3Bucket_Logging (56.73s)
--- PASS: TestAccAWSS3Bucket_namePrefix (40.92s)
--- PASS: TestAccAWSS3Bucket_objectLock (68.34s)
--- PASS: TestAccAWSS3Bucket_Policy (97.07s)
--- PASS: TestAccAWSS3Bucket_region (34.45s)
--- PASS: TestAccAWSS3Bucket_Replication (159.22s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AccessControlTranslation (94.18s)
--- PASS: TestAccAWSS3Bucket_ReplicationConfiguration_Rule_Destination_AddAccessControlTranslation (95.79s)
--- PASS: TestAccAWSS3Bucket_ReplicationExpectVersioningValidationError (28.62s)
--- PASS: TestAccAWSS3Bucket_ReplicationSchemaV2 (167.50s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutPrefix (55.52s)
--- PASS: TestAccAWSS3Bucket_ReplicationWithoutStorageClass (58.02s)
--- PASS: TestAccAWSS3Bucket_RequestPayer (67.28s)
--- PASS: TestAccAWSS3Bucket_shouldFailNotFound (19.65s)
--- PASS: TestAccAWSS3Bucket_tagsWithNoSystemTags (119.32s)
--- PASS: TestAccAWSS3Bucket_tagsWithSystemTags (171.42s)
--- PASS: TestAccAWSS3Bucket_UpdateAcl (65.51s)
--- PASS: TestAccAWSS3Bucket_UpdateGrant (92.38s)
--- PASS: TestAccAWSS3Bucket_Versioning (95.55s)
--- PASS: TestAccAWSS3Bucket_Website_Simple (95.12s)
--- PASS: TestAccAWSS3Bucket_WebsiteRedirect (91.21s)
--- PASS: TestAccAWSS3Bucket_WebsiteRoutingRules (65.48s)
```
  • Loading branch information
bflad committed Jul 13, 2020
1 parent 2fb5645 commit 05fc9c4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 62 deletions.
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
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
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
Expand Up @@ -22,6 +22,7 @@ Upgrade topics:
- [Data Source: aws_lambda_invocation](#data-source-aws_lambda_invocation)
- [Resource: aws_emr_cluster](#resource-aws_emr_cluster)
- [Resource: aws_lb_listener_rule](#resource-aws_lb_listener_rule)
- [Resource: aws_s3_bucket](#resource-aws_s3_bucket)

<!-- /TOC -->

Expand Down Expand Up @@ -314,3 +315,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
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.

0 comments on commit 05fc9c4

Please sign in to comment.