-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Feature/add resource tags for appmesh mesh resource #8111
Feature/add resource tags for appmesh mesh resource #8111
Conversation
44bc6ef
to
15c199a
Compare
Output from acceptance testing:
|
Can we get a review of this please? |
aws/resource_aws_appmesh_mesh.go
Outdated
@@ -127,6 +130,15 @@ func resourceAwsAppmeshMeshRead(d *schema.ResourceData, meta interface{}) error | |||
return fmt.Errorf("error setting spec: %s", err) | |||
} | |||
|
|||
if err := saveTagsAppmesh(conn, d, aws.StringValue(resp.Mesh.Metadata.Arn)); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the preferred style for error handling is
err = saveTagsAppmesh(conn, d, aws.StringValue(resp.Mesh.Metadata.Arn))
if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") {
log.Printf("[WARN] App Mesh service mesh (%s) not found, removing from state", d.Id())
d.SetId("")
return nil
}
if err != nil {
return fmt.Errorf("error saving tags: %s", err)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
aws/resource_aws_appmesh_mesh.go
Outdated
@@ -147,6 +159,15 @@ func resourceAwsAppmeshMeshUpdate(d *schema.ResourceData, meta interface{}) erro | |||
} | |||
} | |||
|
|||
if err := setTagsAppmesh(conn, d, d.Get("arn").(string)); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed too.
15c199a
to
f1fe342
Compare
Re-run tests.
|
@ewbankkit could you review fixes? |
$ make testacc TEST=./aws TESTARGS='-run=TestAccAWSAppmesh/Mesh'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -parallel 20 -run=TestAccAWSAppmesh/Mesh -timeout 120m
=== RUN TestAccAWSAppmesh
=== RUN TestAccAWSAppmesh/Mesh
=== RUN TestAccAWSAppmesh/Mesh/egressFilter
=== RUN TestAccAWSAppmesh/Mesh/tags
=== RUN TestAccAWSAppmesh/Mesh/basic
--- PASS: TestAccAWSAppmesh (115.91s)
--- PASS: TestAccAWSAppmesh/Mesh (115.91s)
--- PASS: TestAccAWSAppmesh/Mesh/egressFilter (44.72s)
--- PASS: TestAccAWSAppmesh/Mesh/tags (50.00s)
--- PASS: TestAccAWSAppmesh/Mesh/basic (21.19s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 115.996s |
@@ -157,7 +180,7 @@ func resourceAwsAppmeshMeshDelete(d *schema.ResourceData, meta interface{}) erro | |||
_, err := conn.DeleteMesh(&appmesh.DeleteMeshInput{ | |||
MeshName: aws.String(d.Id()), | |||
}) | |||
if isAWSErr(err, "NotFoundException", "") { | |||
if isAWSErr(err, appmesh.ErrCodeNotFoundException, "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Could you also replace the hard-coded string value in resourceAwsAppmeshMeshRead()
? https://github.com/terraform-providers/terraform-provider-aws/blob/1bb0dead12829bf6c9da9e3170f52a8f24984497/aws/resource_aws_appmesh_mesh.go#L107
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
} | ||
|
||
// Build the list of what to remove | ||
var remove []*string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to handle the overlapping tags case, e.g. from ECR https://github.com/terraform-providers/terraform-provider-aws/blob/1bb0dead12829bf6c9da9e3170f52a8f24984497/aws/tagsECR.go#L79-L89
See #7052.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it.
aws/tagsAppmesh.go
Outdated
// compare a tag against a list of strings and checks if it should | ||
// be ignored or not | ||
func tagIgnoredAppmesh(t *appmesh.TagRef) bool { | ||
filter := []string{"^aws:", "^appmesh:", "Name"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to exclude Name
and appmesh:
here?
In my testing these tags don't seem to be added automagically and I can add manually:
$ aws --region us-west-2 appmesh tag-resource --resource-arn "arn:aws:appmesh:us-west-2:000000000000:mesh/simpleapp" --tags "key=Name,value=test"
$ aws --region us-west-2 appmesh tag-resource --resource-arn "arn:aws:appmesh:us-west-2:000000000000:mesh/simpleapp" --tags "key=appmesh:k,value=v"
$ aws --region us-west-2 appmesh list-tags-for-resource --resource-arn "arn:aws:appmesh:us-west-2:000000000000:mesh/simpleapp"
{
"tags": [
{
"value": "test",
"key": "Name"
},
{
"value": "v",
"key": "appmesh:k"
}
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I remove Name
and appmesh:
from ignore list
f1fe342
to
f1de04e
Compare
Re-run acctest.
|
f1de04e
to
0aa99f7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for helping review @ewbankkit and for this implementation @kterada0509! LGTM 🚀
--- PASS: TestAccAWSAppmesh (131.28s)
(Fixing the minor unit/linting error on merge so we can get this released today)
|
This has been released in version 2.17.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
Community Note
Reference #8101
Changes proposed in this pull request:
aws_appmesh_mesh
resourceOutput from acceptance testing: