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

r/aws_kms_grant: Add Support for Referencing CMK by ARN #4886

Merged
merged 1 commit into from
Jun 21, 2018

Conversation

brandonstevens
Copy link
Contributor

Fixes #4141

Changes proposed in this pull request:

  • Add Support for Referencing CMK by ARN which includes CMKs in a different AWS accounts

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAWSKmsGrant_*'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAWSKmsGrant_* -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAWSKmsGrant_Basic
--- PASS: TestAWSKmsGrant_Basic (102.16s)
=== RUN   TestAWSKmsGrant_withConstraints
--- PASS: TestAWSKmsGrant_withConstraints (143.80s)
=== RUN   TestAWSKmsGrant_withRetiringPrincipal
--- PASS: TestAWSKmsGrant_withRetiringPrincipal (89.55s)
=== RUN   TestAWSKmsGrant_bare
--- PASS: TestAWSKmsGrant_bare (94.40s)
=== RUN   TestAWSKmsGrant_ARN
--- PASS: TestAWSKmsGrant_ARN (90.32s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	520.244s

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jun 19, 2018
@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. service/kms Issues and PRs that pertain to the kms service. labels Jun 21, 2018
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.

Thanks for this great contribution, @brandonstevens! LGTM with minor nitpick for GovCloud support, which I'll adjust on merge. 🚀

5 tests passed (all tests)
=== RUN   TestAWSKmsGrant_bare
--- PASS: TestAWSKmsGrant_bare (43.02s)
=== RUN   TestAWSKmsGrant_ARN
--- PASS: TestAWSKmsGrant_ARN (43.10s)
=== RUN   TestAWSKmsGrant_withRetiringPrincipal
--- PASS: TestAWSKmsGrant_withRetiringPrincipal (43.62s)
=== RUN   TestAWSKmsGrant_Basic
--- PASS: TestAWSKmsGrant_Basic (44.66s)
=== RUN   TestAWSKmsGrant_withConstraints
--- PASS: TestAWSKmsGrant_withConstraints (65.28s)

parts := strings.Split(id, ":")
if len(parts) != 2 {
return "", "", fmt.Errorf("unexpected format of ID (%q), expected KeyID:GrantID", id)
if strings.HasPrefix(id, "arn:aws:kms") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nitpick: to support GovCloud (US) partition ARNs (arn:aws-us-gov:kms:) with this change, we can just check for the arn: prefix 👍 I'll adjust this on merge as KMS key IDs should never start with that string.

@bflad bflad added this to the v1.24.0 milestone Jun 21, 2018
@bflad bflad merged commit 88b0b27 into hashicorp:master Jun 21, 2018
bflad added a commit that referenced this pull request Jun 21, 2018
@bflad
Copy link
Contributor

bflad commented Jun 25, 2018

This has been released in version 1.24.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 5, 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 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 Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/kms Issues and PRs that pertain to the kms service. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to Create KMS Grant for External CMK
2 participants