-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
#7741: Pinpoint App - Added resource tag support #9460
Conversation
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.
Hi @faishal 👋 Thanks so much for contributing this. Please see the below initial feedback. Reach out if you have any questions or do not have time to implement the items.
aws/resource_aws_pinpoint_app.go
Outdated
@@ -128,6 +128,12 @@ func resourceAwsPinpointApp() *schema.Resource { | |||
}, | |||
}, | |||
}, | |||
"arn": { | |||
Type: schema.TypeString, | |||
Optional: true, |
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.
The ARN of the PinPoint Application cannot be set by the operator, so Optional: true
should be removed. 👍
Optional: true, |
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.
Removed.
aws/resource_aws_pinpoint_app.go
Outdated
@@ -146,9 +154,14 @@ func resourceAwsPinpointAppCreate(d *schema.ResourceData, meta interface{}) erro | |||
|
|||
log.Printf("[DEBUG] Pinpoint create app: %s", name) | |||
|
|||
if v, ok := d.GetOk("tags"); ok { | |||
tags = tagsFromMapPinPointApp(v.(map[string]interface{})) |
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.
Instead of creating a new variable to store the tags, this logic can be moved below the CreateAppInput
declaration and call req.CreateApplicationRequest.Tags =
directly.
req := &pinpoint.CreateAppInput{
CreateApplicationRequest: &pinpoint.CreateApplicationRequest{
Name: aws.String(name),
},
}
if v, ok := d.GetOk("tags"); ok {
req.CreateApplicationRequest.Tags = tagsFromMapPinPointApp(v.(map[string]interface{}))
}
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.
Make sense, Implemented 👍
aws/resource_aws_pinpoint_app.go
Outdated
@@ -193,6 +207,12 @@ func resourceAwsPinpointAppUpdate(d *schema.ResourceData, meta interface{}) erro | |||
return err | |||
} | |||
|
|||
if err := setTagsPinPointApp(conn, d); err != nil { | |||
return fmt.Errorf( | |||
"Error Updating PinPoint App tags: \"%s\"\n%s", |
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.
We prefer to not introduce extra newlines into our error messaging:
return fmt.Errorf("error updating PinPoint Application (%s) tags: %s", d.Id(), 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.
Make sense, Implemented 👍
@@ -2,6 +2,7 @@ package aws | |||
|
|||
import ( | |||
"fmt" | |||
"github.com/hashicorp/terraform/helper/acctest" |
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.
Nit: Go imports should be formatted as stdlib imports, new line, third party imports with each section alphabetically sorted. Tooling like goimports
can help do this automatically in editors. 😄
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.
Didn't know that, Move to correct position based on other files 👍
aws/tagsPinPointApp.go
Outdated
|
||
// getTags is a helper to get the tags for a resource. It expects the | ||
// tags field to be named "tags" | ||
func getTagsPinPointApp(conn *pinpoint.Pinpoint, d *schema.ResourceData, sn string) error { |
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.
The sn
parameter to this function appears to be unused and should be removed.
func getTagsPinPointApp(conn *pinpoint.Pinpoint, d *schema.ResourceData, sn string) error { | |
func getTagsPinPointApp(conn *pinpoint.Pinpoint, d *schema.ResourceData) error { |
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 catch, Removed and updated function call.
@@ -128,6 +128,12 @@ func resourceAwsPinpointApp() *schema.Resource { | |||
}, | |||
}, | |||
}, | |||
"arn": { |
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.
This new attribute is missing documentation in website/docs/r/pinpoint_app.html.markdown
, e.g. (under ## Attributes
)
* `arn` - Amazon Resource Name (ARN) of the PinPoint Application
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.
Added 👍
Optional: true, | ||
Computed: true, | ||
}, | ||
"tags": tagsSchema(), |
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.
This new argument is missing documentation in website/docs/r/pinpoint_app.html.markdown
, e.g. (under ## Arguments
)
* `tags` - (Optional) Key-value mapping of resource tags
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.
Added 👍
@bflad - Thanks for the feedback. I have fixed all of them and ready for another review 🎉 |
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.
Great updates, @faishal, LGTM! 🚀
--- PASS: TestAccAWSPinpointApp_QuietTime (16.03s)
--- PASS: TestAccAWSPinpointApp_basic (16.87s)
--- PASS: TestAccAWSPinpointApp_Tags (33.26s)
--- PASS: TestAccAWSPinpointApp_CampaignHookLambda (38.13s)
This has been released in version 2.22.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
Fixes #7741
Release note for CHANGELOG:
Output from acceptance testing: