-
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
fix aws_kms_public_key.public_key format - must be base64 #19944
Conversation
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.
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)) |
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.
Is this correct? If my understanding is correct output.PublicKey
is already base64 encoded, so should it be returned as is?
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.
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
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.
Ah ... OK, fair enough, I was reading the AWS API docs, didn't realise the Go SDK automatically decoded it. Thanks for clarifying! 👍🏻
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.
Yes ! That's why we need to encode again in base64, so that it can be handled through terraform
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.
Thanks for this fix @cmeichel-treezor , LGTM 🚀
Output of acceptance test:
--- PASS: TestAccDataSourceAwsKmsPublicKey_basic (15.07s)
--- PASS: TestAccDataSourceAwsKmsPublicKey_encrypt (15.17s)
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! |
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. |
Community Note
Closes #20595.
Output from acceptance testing: