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

provider/aws: Support tags for AWS redshift cluster #5356

Merged
merged 1 commit into from
May 24, 2016

Conversation

stack72
Copy link
Contributor

@stack72 stack72 commented Feb 27, 2016

Needed to implement a model of marking that a redshift cluster needed modifying. Without this requestUpdate variable being set, I was getting the following error:

* aws_redshift_cluster.default: [WARN] Error modifying Redshift Cluster (tf-redshift-cluster-4700836719349831525): InvalidParameterCombination: No modifications were requested
            status code: 400, request id: b4cc33fc-dd58-11e5-9c3a-4bb3559cbdb2

The test results are as follows:

make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSRedshiftCluster' 2>~/tf.log
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /vendor/)
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSRedshiftCluster -timeout 120m
=== RUN   TestAccAWSRedshiftCluster_basic
--- PASS: TestAccAWSRedshiftCluster_basic (549.24s)
=== RUN   TestAccAWSRedshiftCluster_tags
--- PASS: TestAccAWSRedshiftCluster_tags (627.55s)
=== RUN   TestAccAWSRedshiftCluster_notPubliclyAccessible
--- PASS: TestAccAWSRedshiftCluster_notPubliclyAccessible (574.28s)
PASS
ok  github.com/hashicorp/terraform/builtin/providers/aws    1751.501s

}

_, err := conn.DeleteTags(&redshift.DeleteTagsInput{
ResourceName: aws.String(arn),
Copy link
Member

Choose a reason for hiding this comment

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

Would this API call fail if you passed name instead of ARN?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure actually TBH - looking now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it will fail. We need to pass the ARN here

@radeksimko
Copy link
Member

Like we discussed in another issue, I'm not a big fan of making more resources dependent on iam:GetUser (effectively on IAM Users).

I'm personally inclined to hold off on merging this before #5030 is in place and then we can leverage that logic to get account ID reliably across multiple environments (EC2 instance, IAM User, federated IAM Role).

@stack72
Copy link
Contributor Author

stack72 commented Mar 14, 2016

With regards to iam:GetUser - I am following a pattern used all over Elasticache and db instance etc

So if we change this, we should change those at the same time

@radeksimko
Copy link
Member

#5030 is merged and account ID is available via meta.(*AWSClient).accountid.

#6503 is fixing the discussed issue for existing resources. Keep in mind that getting the account ID may fail and your function here should expect accountid to potentially be an empty string (and probably raise an error in such cases).

@stack72 stack72 force-pushed the f-aws-redshift-tags branch 3 times, most recently from 79ba676 to 6b58f4e Compare May 8, 2016 19:23
@stack72
Copy link
Contributor Author

stack72 commented May 8, 2016

@radeksimko this has been updated with the new way of building the ARN - please let me know if you are happy with this so I can merge :)

Ideally, I'd like to get this into 0.6.16!

P.


arn, tagErr := buildRedshiftARN(d.Id(), meta.(*AWSClient).accountid, meta.(*AWSClient).region)
if tagErr != nil {
log.Printf("[DEBUG] Error building ARN for Redshift Cluster, not updating Tags for cluster %s", d.Id())
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this is a good idea? Just silently ignore tags update? I think we should rather return this as an error to the user, so they're aware that tags have not been updated and they also know why.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is how it is currently done in db_instance as well

https://github.com/hashicorp/terraform/blob/master/builtin/providers/aws/resource_aws_db_instance.go#L659

I just used the same layout here

Copy link
Member

Choose a reason for hiding this comment

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

Good spot!

87907e2#diff-0b21e21c91dc560c837c95806e2ba913R341
^ @catsby was there any specific intention in making tags update fail silently?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm in favor of returning an error for a failed tag update, but would be happy to let it slide so long as there's a tracking ticket to come back to it.

@radeksimko
Copy link
Member

I left you some comments there. I can run related acceptance tests for Redshift tomorrow morning. Looking at the retry timeouts scares me away, but I'm happy to verify that before merging for you. 😉

@radeksimko radeksimko added the waiting-response An issue/pull request is waiting for a response from the community label May 8, 2016
@radeksimko
Copy link
Member

This is looking ok except the two last things:

  1. silent failure - pending @catsby 's response
  2. two exact same test cases

@stack72
Copy link
Contributor Author

stack72 commented May 9, 2016

@radeksimko if we are under pressure for 0.6.16 can this be a follow up request for these things are they already exist in db_instance and will need to be fixed there too?

@stack72
Copy link
Contributor Author

stack72 commented May 24, 2016

Made the changes as per the review:

  • Return an error if the tags fail
  • Testing of the actual tags

The tags unit test is the same test used everywhere. We can make any changes to these later :)

@josephholsten
Copy link
Contributor

👍 LGTM

@stack72 stack72 merged commit 1df8290 into hashicorp:master May 24, 2016
@stack72 stack72 deleted the f-aws-redshift-tags branch May 24, 2016 17:43
@ghost
Copy link

ghost commented Apr 25, 2020

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants