diff --git a/.changelog/19944.txt b/.changelog/19944.txt new file mode 100644 index 00000000000..c75c04dbb42 --- /dev/null +++ b/.changelog/19944.txt @@ -0,0 +1,3 @@ +```release-note:bug +data-source/aws_kms_public_key: Correctly base64 encode `public_key` value +``` \ No newline at end of file diff --git a/aws/data_source_aws_kms_public_key.go b/aws/data_source_aws_kms_public_key.go index 427564302c6..13d5391df68 100644 --- a/aws/data_source_aws_kms_public_key.go +++ b/aws/data_source_aws_kms_public_key.go @@ -1,6 +1,7 @@ package aws import ( + "encoding/base64" "fmt" "github.com/aws/aws-sdk-go/aws" @@ -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)) if err := d.Set("encryption_algorithms", flattenStringList(output.EncryptionAlgorithms)); err != nil { return fmt.Errorf("error setting encryption_algorithms: %w", err)