(synthetics): auto delete underlying resources handler returns a misspelled PhysicalResourceId on Create

Open Beginner friendly
#39,629 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@blacksoxx is already working on this.

Since Nov 4, 2026.

  • #39630 by @blacksoxx — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
87/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
aws, node.js, typescript

Research direction

Read packages/@aws-cdk/custom-resource-handlers/lib/aws-synthetics/auto-delete-underlying-resources-handler/index.ts at line 16 and inspect the Create response. The body identifies the misspelled key and describes the expected behavior; the reproduction shows the failing result. Done when Create returns PhysicalResourceId set to the canary name and the handler unit tests pass.

Written by the indexing model from the issue text.

Description

@aws-cdk/aws-synthetics bug effort/small p2
Describe the bug

The Custom::SyntheticsAutoDeleteUnderlyingResources handler answers a Create event with { PhyscialResourceId: <canary name> }. The key is misspelled, so the entrypoint ignores it and records the CloudFormation request id as the physical resource id instead of the canary name.

The Update path returns the canary name and relies on CloudFormation comparing it with the id recorded at Create to decide whether a Delete for the old resource is needed (see the comment in onUpdate). With the request id recorded at Create, the first Update of the custom resource whose properties change for a reason other than the canary name (the ServiceToken, for example) returns a different physical id, CloudFormation treats it as a replacement and sends a Delete with the old properties. That Delete finds the canary tagged aws-cdk:auto-delete-underlying-resources and deletes the Lambda function behind the live canary.

Handler: packages/@aws-cdk/custom-resource-handlers/lib/aws-synthetics/auto-delete-underlying-resources-handler/index.ts, line 16.

Regression Issue
  • Select this option if this issue appears to be a regression.
Last Known Working CDK Library Version

The line has been misspelled since the handler was added in #26580.

Expected Behavior

The Create response carries PhysicalResourceId set to the canary name, so an Update that keeps the canary name does not change the physical id.

Current Behavior

The Create response has no PhysicalResourceId; the physical id becomes the request id. An Update that keeps the canary name changes the physical id to the canary name.

Reproduction Steps
const result = await autoDeleteHandler({
  RequestType: 'Create',
  ResourceProperties: { ServiceToken: 'Foo', CanaryName: 'MyCanary' },
});
// result is { PhyscialResourceId: 'MyCanary' }, result.PhysicalResourceId is undefined

A synthetics.Canary with cleanup: synthetics.Cleanup.LAMBDA shows the request id as the physical id of AutoDeleteUnderlyingResourcesCustomResource in the CloudFormation console after the first deployment.

Possible Solution

Spell the key PhysicalResourceId.

AWS CDK Library version (aws-cdk-lib)

2.275.0 (handler source identical on main at 2674cecfc7)

AWS CDK CLI version

Not used for the reproduction; the handler was exercised with the package unit tests.

Node.js Version

v26.5.0 (local unit test run)

OS

macOS (Darwin 25.6.0)

Language

TypeScript

Dominant language
TypeScript
Stars
13k
Forks
4.7k
Avg merge
4d 3h
Merged PRs (30d)
98

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from aws/aws-cdk

All issues in aws/aws-cdk

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.