diff --git a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts index b95c8164dc1b5..977ea15cbec4c 100644 --- a/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts +++ b/packages/aws-cdk-lib/aws-synthetics/lib/canary.ts @@ -354,16 +354,16 @@ export class Canary extends cdk.Resource implements ec2.IConnectable { validateName(props.canaryName); } - if (props.cleanup === Cleanup.LAMBDA && props.provisionedResourceCleanup) { - throw new Error('Cannot specify `provisionedResourceCleanup` when `cleanup` is set to `Cleanup.LAMBDA`. Use only `provisionedResourceCleanup`.'); - } - super(scope, id, { physicalName: props.canaryName || cdk.Lazy.string({ produce: () => this.generateUniqueName(), }), }); + if (props.cleanup === Cleanup.LAMBDA && props.provisionedResourceCleanup) { + throw new ValidationError('Cannot specify `provisionedResourceCleanup` when `cleanup` is set to `Cleanup.LAMBDA`. Use only `provisionedResourceCleanup`.', this); + } + this.artifactsBucket = props.artifactsBucketLocation?.bucket ?? new s3.Bucket(this, 'ArtifactsBucket', { encryption: s3.BucketEncryption.KMS_MANAGED, enforceSSL: true,