Terraform v0.11.11
provider "aws" {
region = "ap-southeast-1"
}
data "aws_s3_bucket_object" "test" {
bucket = "test-terraform-s3-bucket-object"
key = "test"
}
resource "null_resource" "test" {
provisioner "local-exec" {
command = "aws s3api head-object --bucket 'test-terraform-s3-bucket-object' --key 'test' --query 'Metadata'"
}
}
output "metadata" {
value = "${data.aws_s3_bucket_object.test.metadata}"
}
The output of data.aws_s3_bucket_object.test.metadata key name should be the same as aws cli and aws S3 console (e.g. test )
metadata = {
test = Test Bucket Object
}
The key name automatic capitalize the first letter (e.g. Test instead of test )
metadata = {
Test = Test Bucket Object
}
terraform applyUser-defined metadata keys are stored in lowercase:
Thank @ewbankkit for the doc, then clearly the Metadata keys returned should be in lowercase.
Yes, I'll try and dig in to this when I get time.
It looks like there is an underlying issue with the AWS SDK: https://github.com/aws/aws-sdk-go/issues/445.
Related:
Thanks, I think the issue has been noticed before and PR is ready. In the meanwhile, since the metadata key always is lowercase, I do a workaround by casting to lowercase.
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!