(@aws-cdk/aws-codepipeline-actions): Not able to deploy to s3 bucket with KMS encryption
See original GitHub issueI have a pipeline the finnal step is to move the outcome into an existing s3 bucket, created in another stack.
const publishBucket = s3.Bucket.fromBucketName(
this,
'PublishBucket',
serviceBundleBucket
);
const publishAction = new codepipeline_actions.S3DeployAction({
actionName: 'Publish',
bucket: targetBucket,
objectKey: bucketKey,
input: this.outputArtifact,
extract: false,
});
The target bucket is
-
created from another stack
-
encrypted with KMS custom key, with rotation enabled.
It works with encryption with S3_managed, but not KMS.
Also tested, it works with KMS key if the bucket is created in the same stack.
Reproduction Steps
- create a pipeline
- look up a s3 bucket (encrypted with KMS key, created outside the stack)
- add final action to deploy to a s3 bucket
- deploy failed with error
You do not have sufficient permissions to call s3.putObject for the deployment bucket, ags.pes.opa.bundle-personal-test.split-stack. Verify that the policy on the resource allows you to perform this task. If you choose a canned ACL for your Amazon S3 deployment action, the policy must include the PutObjectAcl action. If the object already exists, the policy must also include the PutObjectVersionAcl action. Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: P963NYR7SFEKP4PD; S3 Extended Request ID: /1iwx2GLmjA3PUgaKmiqEEd5msttkjXzeJkdhRHe/ASiQibEmPeO5OaYt4vosmYDg9CHip7/Sqs=; Proxy: null)
What did you expect to happen?
deploy success
What actually happened?
deploy failed at the S3DeployAction
Environment
- **CDK CLI Version : 1.93.0
- **Framework Version:1.93.0
- **Node.js Version:v12.18.3
- **OS :mac 14.0
- **Language (Version): ts 4.1.x
Other
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Access denied when uploading to KMS-encrypted Amazon S3 ...
My Amazon Simple Storage Service (Amazon S3) bucket has AWS Key Management Service (AWS KMS) default encryption. I'm trying to upload files to...
Read more >Using server-side encryption with AWS Key Management ...
AWS KMS generates a data key, encrypts it under the KMS key, and sends both the plaintext data key and the encrypted data...
Read more >Upload to KMS-encrypted Bucket not possible due to missing ...
Describe the bug We are trying to upload documents to a S3 Bucket: this.staticPageBucket = new s3.Bucket(this, "MyBucket", { encryption: s3.
Read more >Not able to Put data/object into S3 bucket using Glue Job ...
1> To PutObject and encrypt it, add "kms:GenerateDataKey" with key ID as a resource. 2> To GetObject (and decrypt it), "kms:Decrypt" (which you ......
Read more >How can I allow users to access my S3 bucket that's encrypted ...
How can I allow users to access my S3 bucket that's encrypted with a custom AWS KMS key?
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can confirm it works as @skinny85 suggested, for the benefit of other people steps into this issue. you need something like:
Closing the issue, thanks again for your quick response.
The Key should be passed as part of the Bucket, when you import it using
fromBucketAttributes()
with theencryptionKey
property filled.