Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mazyu36 committed Nov 6, 2024
1 parent 2eaacec commit 45ccec0
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions packages/aws-cdk-lib/aws-synthetics/lib/canary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export interface CanaryProps {
* Artifact encryption is only supported for canaries that use Synthetics runtime
* version `syn-nodejs-puppeteer-3.3` or later.
*
* @default - `ArtifactsEncryptionMode.KMS` is set if you specify `artifactS3KmsKey`, otherwise artifacts are encrypted at rest using an AWS managed key
* @default - Artifacts are encrypted at rest using an AWS managed key. `ArtifactsEncryptionMode.KMS` is set if you specify `artifactS3KmsKey`.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_artifact_encryption.html
*/
Expand Down Expand Up @@ -687,23 +687,16 @@ export class Canary extends cdk.Resource implements ec2.IConnectable {
throw new Error(`Artifact encryption is only supported for canaries that use Synthetics runtime version \`syn-nodejs-puppeteer-3.3\` or later, got \`${props.runtime.name}\`.`);
}

const encryptionMode = props.artifactS3EncryptionMode ? props.artifactS3EncryptionMode :
props.artifactS3KmsKey ? ArtifactsEncryptionMode.KMS : undefined;

let encryptionKey: kms.IKey | undefined;
if (props.artifactS3EncryptionMode === ArtifactsEncryptionMode.KMS && !props.artifactS3KmsKey) {
encryptionKey = new kms.Key(this, 'Key', { description: `Created by ${this.node.path}` });
} else {
encryptionKey = props.artifactS3KmsKey;
if (encryptionMode === ArtifactsEncryptionMode.KMS) {
encryptionKey = props.artifactS3KmsKey ?? new kms.Key(this, 'Key', { description: `Created by ${this.node.path}` });
}

encryptionKey?.grantEncryptDecrypt(this.role);

let encryptionMode: ArtifactsEncryptionMode | undefined;

if (props.artifactS3KmsKey && !props.artifactS3EncryptionMode) {
encryptionMode = ArtifactsEncryptionMode.KMS;
} else {
encryptionMode = props.artifactS3EncryptionMode;
}

return {
s3Encryption: {
encryptionMode,
Expand Down

0 comments on commit 45ccec0

Please sign in to comment.