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

Updates to tags and ACLs should happen only for non new resources #5072

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion aws/resource_aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error {
}
}
if d.HasChange("volume_tags") {
if !d.IsNewResource() || !restricted {
if !d.IsNewResource() || restricted {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding here is that "restricted" e.g. "gov cloud" accounts don't yet have the option to add tags at creation time so you need to set them afterwards. This change brings the behaviour in line with similar approach on line 848.

if err := setVolumeTags(conn, d); err != nil {
return err
} else {
Expand Down
2 changes: 1 addition & 1 deletion aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ func resourceAwsS3BucketUpdate(d *schema.ResourceData, meta interface{}) error {
return err
}
}
if d.HasChange("acl") {
if d.HasChange("acl") && !d.IsNewResource() {
if err := resourceAwsS3BucketAclUpdate(s3conn, d); err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions aws/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func diffTags(oldTags, newTags []*ec2.Tag) ([]*ec2.Tag, []*ec2.Tag) {
old, ok := create[*t.Key]
if !ok || old != *t.Value {
remove = append(remove, t)
} else if ok {
// already present so remove from new
delete(create, *t.Key)
}
}

Expand Down
18 changes: 18 additions & 0 deletions aws/tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ func TestDiffTags(t *testing.T) {
"foo": "bar",
},
},

// Overlap
{
Old: map[string]interface{}{
"foo": "bar",
"hello": "world",
},
New: map[string]interface{}{
"foo": "baz",
"hello": "world",
},
Create: map[string]string{
"foo": "baz",
},
Remove: map[string]string{
"foo": "bar",
},
},
}

for i, tc := range cases {
Expand Down