-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(s3-deployment): User metadata keys have redundant triple x-amz
prefix
#12414
Conversation
This comment has been minimized.
This comment has been minimized.
@iliapolo @ayush987goyal The S3 service which is accessed by the CLI command which the aws-cdk/packages/@aws-cdk/aws-s3-deployment/lib/lambda/index.py Lines 142 to 143 in bf059fa
seems to already adds the |
Yeah, I confirmed that without even using this library, running $ AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=my-profile \
aws s3 sync ./my-contents/ s3://my-bucket//my-path/ \
--metadata '{ "x-amz-meta-sourceurl": "static" }' \
--metadata-directive REPLACE results in duplicate I'll update this patch to remove adding the prefix in TS and Python entirely. |
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.
@bmwalters This is great. It was indeed pretty messy, my only question/concern is how is this going to affect existing objects in the bucket? will their metadata change?
Yes, the metadata keys will change. For example, to access metadata created by s3-deployment using an SDK: // before
let metadata = s3Object.metadata?["x-amz-meta-x-amzn-meta-mykey"]
// after
let metadata = s3Object.metadata?["mykey"] The previous version is awkward so I'm not sure how many users there actually are. If we want to preserve the incorrect metadata keys as well we could internally duplicate each key, so if the user passes in "mykey" they end up with both "x-amz-meta-mykey" and "x-amz-meta-x-amz-meta-x-amzn-meta-mykey". Otherwise this could be listed as a potentially breaking change. |
@bmwalters Ok, lets mention this as a breaking change 👍
|
Without this fix, keys are prefixed with x-amzn-meta- by the TypeScript code, then the Python code runs and prefixes metadata keys again with x-amz-meta-. Then, the Python shells out to aws-cli which makes a request to the S3 service. There, the keys are prefixed *yet again* with x-amz-meta- _unconditionally_. Thus no matter what keys the user specified, the keys in S3 would be: x-amz-meta-x-amz-meta-x-amzn-meta-<user input>. This issue was originally reported as #8459. After this change, neither the TypeScript code nor the Python code will attempt to prepend to the metadata key. Instead we rely on the S3 service to do it.
Pull request has been modified.
x-amz
prefix
x-amz
prefixx-amz
prefix
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…prefix (aws#12414) Without this fix, keys are prefixed with x-amzn-meta- by the TypeScript code, then the Python code runs and prefixes metadata keys again with x-amz-meta-. Then, the Python shells out to aws-cli which makes a request to the S3 service. There, the keys are prefixed *yet again* with x-amz-meta- _unconditionally_. Thus no matter what keys the user specified, the keys in S3 would be: x-amz-meta-x-amz-meta-x-amzn-meta-<user input>. This issue was originally reported as aws#8459. aws#10678 attempted to fix this issue, and fixed the Python, but missed the TS. It also suffers from the S3 service adding the prefix unconditionally. After this change, neither the TypeScript code nor the Python code will attempt to prepend to the metadata key. Instead we rely on the S3 service to do it. BREAKING CHANGE: User metadata keys of bucket objects will change from `x-amz-meta-x-amz-meta-x-amzn-meta-mykey` to `x-amz-meta-mykey`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Without this fix, keys are prefixed with x-amzn-meta- by the TypeScript code,
then the Python code runs and prefixes metadata keys again with x-amz-meta-.
Then, the Python shells out to aws-cli which makes a request to the S3 service.
There, the keys are prefixed yet again with x-amz-meta- unconditionally.
Thus no matter what keys the user specified, the keys in S3 would be:
x-amz-meta-x-amz-meta-x-amzn-meta-.
This issue was originally reported as #8459.
#10678 attempted to fix this issue, and fixed the Python, but missed the TS.
It also suffers from the S3 service adding the prefix unconditionally.
After this change, neither the TypeScript code nor the Python code will attempt
to prepend to the metadata key. Instead we rely on the S3 service to do it.
BREAKING CHANGE: User metadata keys of bucket objects will change from
x-amz-meta-x-amz-meta-x-amzn-meta-mykey
tox-amz-meta-mykey
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license