(s3): dependency not added when key alias provided as encryptionKey to bucket #25761
Labels
@aws-cdk/aws-kms
Related to AWS Key Management
@aws-cdk/aws-s3
Related to Amazon S3
bug
This issue is a bug.
effort/small
Small work item – less than a day of effort
p1
Describe the bug
Our team has an S3
Bucket
construct that uses a KMSAlias
construct as its (theBucket
's)encryptionKey
. When the CDK code is compiled down to CloudFormation, theBucketEncryption
.ServerSideEncryptionConfiguration
.KMSMasterKeyID
compiles down to something likeinstead of something like
which was unexpected.
This impacted us in production in the following way. We had already deployed our
Bucket
previously, and writes to theBucket
are on the critical path for some of our APIs. We wanted to deploy theKey
and correspondingAlias
as well, so we did so. However, during the deployment for about 2 minutes, the APIs for which theBucket
is on the critical path were giving Internal Server Errors due toAmazonS3Exception: Alias <ALIAS_ARN> is not found.
. We found that this was because, without a logical dependency betweenBucket
andAlias
, theBucket
'sencryptionKey
was updated before theAlias
had been created.Expected Behavior
We expected the
BucketEncryption
.ServerSideEncryptionConfiguration
.KMSMasterKeyID
to compile down to something likeso that there would be a logical dependency between the
Bucket
and theAlias
, which is what you would expect from looking at the CDK code.Current Behavior
The
BucketEncryption
.ServerSideEncryptionConfiguration
.KMSMasterKeyID
compiled down to something likeinstead.
Reproduction Steps
Create a stack consisting only of the following CDK constructs:
Possible Solution
When attaching an
IKey
to a resource, check if theIKey
is anAlias
, and if so, compile down to a reference instead of an ARN.Additional Information/Context
No response
CDK CLI Version
2.14.0
Framework Version
No response
Node.js Version
14.21.3
OS
Amazon Linux 2
Language
Typescript
Language Version
Typescript (4.3.0)
Other information
No response
The text was updated successfully, but these errors were encountered: