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

fix aws_kms_public_key.public_key format - must be base64 #19944

Merged
merged 3 commits into from
Aug 25, 2021

Conversation

cmeichel-treezor
Copy link
Contributor

@cmeichel-treezor cmeichel-treezor commented Jun 24, 2021

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" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #20595.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

@github-actions github-actions bot added service/kms Issues and PRs that pertain to the kms service. needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. labels Jun 24, 2021
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome @cmeichel-treezor 👋

It looks like this is your first Pull Request submission to the Terraform AWS Provider! If you haven’t already done so please make sure you have checked out our CONTRIBUTING guide and FAQ to make sure your contribution is adhering to best practice and has all the necessary elements in place for a successful approval.

Also take a look at our FAQ which details how we prioritize Pull Requests for inclusion.

Thanks again, and welcome to the community! 😃

@@ -75,7 +76,7 @@ func dataSourceAwsKmsPublicKeyRead(d *schema.ResourceData, meta interface{}) err
d.Set("arn", output.KeyId)
d.Set("customer_master_key_spec", output.CustomerMasterKeySpec)
d.Set("key_usage", output.KeyUsage)
d.Set("public_key", string(output.PublicKey))
d.Set("public_key", base64.StdEncoding.EncodeToString(output.PublicKey))

Choose a reason for hiding this comment

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

Is this correct? If my understanding is correct output.PublicKey is already base64 encoded, so should it be returned as is?

Copy link
Contributor

@anGie44 anGie44 Aug 17, 2021

Choose a reason for hiding this comment

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

From the AWS Go SDK Documentation https://docs.aws.amazon.com/sdk-for-go/api/service/kms/#GetPublicKeyOutput

PublicKey is automatically base64 encoded/decoded by the SDK

@chrisclayson in this case I think we'd have to encode this API response value

Choose a reason for hiding this comment

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

Ah ... OK, fair enough, I was reading the AWS API docs, didn't realise the Go SDK automatically decoded it. Thanks for clarifying! 👍🏻

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 ! That's why we need to encode again in base64, so that it can be handled through terraform

@anGie44 anGie44 added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 24, 2021
@anGie44 anGie44 self-assigned this Aug 24, 2021
@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Aug 24, 2021
@github-actions github-actions bot added documentation Introduces or discusses updates to documentation. and removed documentation Introduces or discusses updates to documentation. labels Aug 24, 2021
Copy link
Contributor

@anGie44 anGie44 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 fix @cmeichel-treezor , LGTM 🚀

Output of acceptance test:

--- PASS: TestAccDataSourceAwsKmsPublicKey_basic (15.07s)
--- PASS: TestAccDataSourceAwsKmsPublicKey_encrypt (15.17s)

@anGie44 anGie44 added this to the v3.56.0 milestone Aug 24, 2021
@anGie44 anGie44 merged commit a99fcfb into hashicorp:main Aug 25, 2021
@github-actions
Copy link

This functionality has been released in v3.56.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. Thank you!

@github-actions
Copy link

I'm going to lock this pull request 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 related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. documentation Introduces or discusses updates to documentation. service/kms Issues and PRs that pertain to the kms service. size/XS Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_kms_public_key.public_key returning malformed data
5 participants