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

AWS S3 Object: Support seamless upgrade from provider v4.x #33138

Merged
merged 5 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions .changelog/33138.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```release-note:bug
resource/aws_s3_object: Mark `acl` as Computed. This suppresses the diffs shown when migrating resources with no configured `acl` attribute value from v4.67.0 (or earlier)
```

```release-note:bug
resource/aws_s3_object_copy: Mark `acl` as Computed. This suppresses the diffs shown when migrating resources with no configured `acl` attribute value from v4.67.0 (or earlier)
```
1 change: 1 addition & 0 deletions internal/service/s3/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func ResourceObject() *schema.Resource {
"acl": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice(s3.ObjectCannedACL_Values(), false),
},
"bucket": {
Expand Down
1 change: 1 addition & 0 deletions internal/service/s3/object_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func ResourceObjectCopy() *schema.Resource {
"acl": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ValidateFunc: validation.StringInSlice(s3.ObjectCannedACL_Values(), false),
ConflictsWith: []string{"grant"},
},
Expand Down
32 changes: 32 additions & 0 deletions internal/service/s3/object_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,38 @@ func TestAccS3Object_empty(t *testing.T) {
})
}

func TestAccS3Object_upgradeFromV4(t *testing.T) {
ctx := acctest.Context(t)
var obj s3.GetObjectOutput
resourceName := "aws_s3_object.object"
rName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { acctest.PreCheck(ctx, t) },
ErrorCheck: acctest.ErrorCheck(t, s3.EndpointsID),
CheckDestroy: testAccCheckObjectDestroy(ctx),
Steps: []resource.TestStep{
{
ExternalProviders: map[string]resource.ExternalProvider{
"aws": {
Source: "hashicorp/aws",
VersionConstraint: "4.67.0",
},
},
Config: testAccObjectConfig_empty(rName),
Check: resource.ComposeTestCheckFunc(
testAccCheckObjectExists(ctx, resourceName, &obj),
),
},
{
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
Config: testAccObjectConfig_empty(rName),
PlanOnly: true,
},
},
})
}

func TestAccS3Object_source(t *testing.T) {
ctx := acctest.Context(t)
var obj s3.GetObjectOutput
Expand Down
Loading