aws_ssm - apply bucket SSE settings when uploading files to the managed node - #3052
Open
obispobruno wants to merge 1 commit into
Open
aws_ssm - apply bucket SSE settings when uploading files to the managed node#3052obispobruno wants to merge 1 commit into
obispobruno wants to merge 1 commit into
Conversation
…ed node The connection plugin only generated server-side-encryption settings for fetch_file (node to controller) transfers. put_file transfers uploaded the file from the controller with upload_fileobj(ExtraArgs=None), so no encryption settings were applied and buckets whose policy denies unencrypted PutObject requests rejected every controller to node file transfer with AccessDenied. Mirror the fetch_file branch's generate_encryption_settings() call in the put branch of S3ClientManager.generate_host_commands() so the returned put_args reach upload_fileobj as ExtraArgs. Fixes ansible-collections#3018
1 task
Contributor
|
Build failed. ❌ ansible-galaxy-importer RETRY_LIMIT Host unreachable in 6m 25s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUMMARY
Fixes #3018
The
aws_ssmconnection plugin only generates server-side-encryption settings forfetch_file(node→controller) transfers. Forput_file(controller→node) transfers, theputbranch ofS3ClientManager.generate_host_commands()leavesput_argsasNone, so the controller-side upload runsupload_fileobj(ExtraArgs=None)and no encryption settings are applied.When the transfer bucket has a policy that denies unencrypted
PutObjectrequests (e.g. the commonDenyIncorrectEncryptionHeaderpattern requiringx-amz-server-side-encryption), every controller→node file transfer fails withAccessDeniedand the host becomes UNREACHABLE on the first transfer.This change mirrors the
getbranch'sgenerate_encryption_settings()call in theputbranch, so the returnedput_argsreachupload_fileobjasExtraArgs, matching the documentedbucket_sse_mode/bucket_sse_kms_key_idbehaviour for both transfer directions.Unit tests updated accordingly: the
putcases oftest_generate_host_commandsnow assert that encryption settings are generated and returned (previously they asserted the settings were not generated).As suggested in #3018 (comment), the integration test setup is also hardened so this can't regress silently: when the connection is configured to send SSE headers (
bucket_sse_modeset, i.e.encrypted_bucketwithouts3_bucket_encryption), the transfer bucket now gets aDenyIncorrectEncryptionHeaderpolicy rejecting anyPutObjectwithout the matchingx-amz-server-side-encryptionheader. Default bucket encryption alone can't catch a missing header, because S3 then encrypts the object anyway — which is whyconnection_aws_ssm_encrypted_s3previously passed despite this bug.ISSUE TYPE
COMPONENT NAME
aws_ssm
ADDITIONAL INFORMATION
Reproduced with a transfer bucket carrying this policy statement (bucket
sse_modeAES256):{ "Sid": "DenyIncorrectEncryptionHeader", "Effect": "Deny", "Principal": "*", "Action": "s3:PutObject", "Resource": "arn:aws:s3:::<transfer-bucket>/*", "Condition": { "StringNotEquals": { "s3:x-amz-server-side-encryption": "AES256" } } }Before the fix, every playbook fails on its first file transfer:
With the fix applied, transfers in both directions succeed. Verified in a live environment (Ubuntu EC2 instance over SSM,
bucket_sse_mode: AES256).