-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(core): unused cross-region exports can't be deleted #27902
Copy link
Copy link
Open
Labels
@aws-cdk/coreRelated to core CDK functionalityRelated to core CDK functionalitybugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp1
Description
Describe the bug
If a stack maintains multiple cross-region exports, and some subset of cross-region exports are being imported by other stacks, attempting to remove any cross-region export value that is not being used (imported) by any deployed stack:
❯ cdk diff [...] --exclusively
[...]
[~] Custom::CrossRegionExportWriter ExportsWriteruswest2[...]
ExportsWriteruswest2[...]
└─ [~] WriterProps
└─ [~] .exports:
└─ [-] Removed: ./cdk/exports/unused-value/anotherstackuseast1Ref[...]certificate[...]
Fails with the following error on cdk deploy:
ExportsWriteruswest2[...]/Resource/Default (ExportsWriteruswest2[...]) Received response status [FAILED] from custom resource. Message returned: Error: Exports cannot be updated:
at throwIfAnyInUse (/var/task/index.js:4:10)
Other issues don't describe this bug:
- several closed issues reference cross-region exports ((core): crossRegionReference only works for first destination region #24464, core: CrossRegionExportReader: Response object is too long #25114), but these concern creating exports not deleting them
- many closed issues reference removing cross-stack exports (No longer accessing another stack's resource causes deadly embrace #7602), but cross-stack exports that are not also cross-region don't use the ExportsWriter lambda and can't produce the failure mode
- the Stack.export_value function does not export values across regions, only across stacks, so it can't be used to create a "dummy" cross-region export for this ExportsWriter lambda
Expected Behavior
CDK should fail to deploy with the error above only if the cdk diff shows an export being removed that is currently imported by another stack.
Current Behavior
CDK fails to deploy with the error above even when cdk diff shows only exports being removed that are not currently imported by another stack.
Reproduction Steps
- Create two cross-region exports, exported from stack A into another stack B in a different region.
- Remove one of the two imports from stack B and deploy stack B exclusively. Observe that one import is removed from stack B's
["CrossRegionExportReader"]["ReaderProps"]template in the CloudFormation console. - Attempt to deploy stack A. Observe one of the two exports being removed in the diff. Observe that on the deploy, the ExportWriter fails to update and the deploy fails with the error above.
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.94.0 (build 987c329)
Framework Version
No response
Node.js Version
v18.17.1
OS
macOS
Language
Python
Language Version
Python (3.10.4)
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/coreRelated to core CDK functionalityRelated to core CDK functionalitybugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp1