-
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
data.aws_kms_alias: Use kms:DescribeKey to get target key Id & ARN #3304
Conversation
@handlerbot wow this is awesome, good find! Is there a point to calling |
} | ||
resp, err := conn.DescribeKey(req) | ||
if err != nil { | ||
return errwrap.Wrapf("Error calling KMS DescribeKey: {{err}}", 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.
FYI I know there are a bunch of places in the repository currently using this, but we don't need the context wrapping of errwrap
when we're just returning an error message. fmt.Errorf
is just fine 😄
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.
OK, got it. Want I should fix this, or merge and do a global sweep & cleanup later?
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'll do it later, no sense holding this up. 👍
@bflad I thought about that (giving up on Here's how it goes:
So, we could switch this implementation to only calling Thus: it really depends on how ideologically one feels about synthesizing ARNs (and risking there being bugs or needing a priority upgrade in the future if AWS changes something about ARNs suddenly) vs getting them direct from AWS responses without having to do any post-processing of them. I decided I liked the latter approach, at the expense of having to to do two API calls rather than one, so that's where I landed. Also, I think you can't resolve KMS aliases cross-account, as there is no policy you can attach to aliases to specify that account X and Y have permission to resolve an alias to a key ID; when I have done this in Terraform, it was by creating an AWS provider for the second account, and using that provider for the |
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.
LGTM! Thanks for finding this and contributing the fix!
make testacc TEST=./aws TESTARGS='-run=TestAccDataSourceAwsKmsAlias'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccDataSourceAwsKmsAlias -timeout 120m
=== RUN TestAccDataSourceAwsKmsAlias_AwsService
--- PASS: TestAccDataSourceAwsKmsAlias_AwsService (12.22s)
=== RUN TestAccDataSourceAwsKmsAlias_CMK
--- PASS: TestAccDataSourceAwsKmsAlias_CMK (42.14s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 54.423s
This has been released in version 1.10.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Context/fixes: #2009 (comment)
make testacc TESTARGS='-run=TestAccDataSourceAwsKmsAlias'
passes.cc @bflad @trung