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

#7741: Pinpoint App - Added resource tag support #9460

Merged
merged 3 commits into from
Jul 31, 2019

Conversation

faishal
Copy link
Contributor

@faishal faishal commented Jul 23, 2019

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Fixes #7741

Release note for CHANGELOG:

resource/aws_pinpoint_app: Add tags argument (https://github.com/terraform-providers/terraform-provider-aws/issues/7741)

Output from acceptance testing:

$ make testacc TESTARGS='-run= TestAccAWSPinpointApp_Tags'

PASS

@faishal faishal requested a review from a team July 23, 2019 15:18
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. service/pinpoint Issues and PRs that pertain to the pinpoint service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Jul 23, 2019
Copy link
Contributor

@bflad bflad left a 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.

@@ -128,6 +128,12 @@ func resourceAwsPinpointApp() *schema.Resource {
},
},
},
"arn": {
Type: schema.TypeString,
Optional: true,
Copy link
Contributor

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. 👍

Suggested change
Optional: true,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

@@ -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{}))
Copy link
Contributor

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{}))
	}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense, Implemented 👍

@@ -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",
Copy link
Contributor

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)

Copy link
Contributor Author

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"
Copy link
Contributor

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. 😄

Copy link
Contributor Author

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 👍


// 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 {
Copy link
Contributor

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.

Suggested change
func getTagsPinPointApp(conn *pinpoint.Pinpoint, d *schema.ResourceData, sn string) error {
func getTagsPinPointApp(conn *pinpoint.Pinpoint, d *schema.ResourceData) error {

Copy link
Contributor Author

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": {
Copy link
Contributor

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

Copy link
Contributor Author

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(),
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added 👍

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. waiting-response Maintainers are waiting on response from community or contributor. labels Jul 30, 2019
@bflad bflad self-assigned this Jul 30, 2019
@ghost ghost added the documentation Introduces or discusses updates to documentation. label Jul 31, 2019
@faishal
Copy link
Contributor Author

faishal commented Jul 31, 2019

@bflad - Thanks for the feedback. I have fixed all of them and ready for another review 🎉

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Jul 31, 2019
@bflad bflad self-requested a review July 31, 2019 14:56
@bflad bflad added this to the v2.22.0 milestone Jul 31, 2019
Copy link
Contributor

@bflad bflad left a 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)

@bflad bflad merged commit dd2d66a into hashicorp:master Jul 31, 2019
bflad added a commit that referenced this pull request Jul 31, 2019
@faishal faishal deleted the 7741-pinpoint-tags branch July 31, 2019 15:31
@ghost
Copy link

ghost commented Aug 1, 2019

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!

@ghost
Copy link

ghost commented Nov 2, 2019

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!

@ghost ghost locked and limited conversation to collaborators Nov 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/pinpoint Issues and PRs that pertain to the pinpoint service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Amazon Pinpoint resources: Add support for resource tags
2 participants