Skip to content

Commit

Permalink
Add dummy exports
Browse files Browse the repository at this point in the history
CDK has a limitation where if you attempt to remove all references to
a resource from another stack, CDK will attempt to remove the export
for that resource, which then fails because it sees there is still an
external dependency on that resource, creating a 'deadly embrace'
See aws/aws-cdk#12778.

The workaround for this is to set dummy export values to trick CDK
into keeping the unused exports around until you've deployed your
updates to the dependent stack.
  • Loading branch information
landonshumway-ia committed Nov 19, 2024
1 parent 83af375 commit 86ceca7
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions backend/compact-connect/stacks/persistent_stack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,32 @@ def _add_mock_data_resources(self):
event_bus=self.data_event_bus,
)

# These dummy exports are required until we remove dependencies from the api stack
# see https://github.com/aws/aws-cdk/issues/3414
self.export_value(self.mock_bulk_uploads_bucket.bucket_name)
self.export_value(self.mock_bulk_uploads_bucket.bucket_arn)

self.mock_license_table = LicenseTable(
self, 'MockLicenseTable', encryption_key=self.shared_encryption_key, removal_policy=RemovalPolicy.DESTROY
self, 'MockLicenseTable', encryption_key=self.shared_encryption_key,
removal_policy=RemovalPolicy.DESTROY
)

# These dummy exports are required until we remove dependencies from the api stack
# see https://github.com/aws/aws-cdk/issues/3414
self.export_value(self.mock_license_table.table_name)
self.export_value(self.mock_license_table.table_arn)

def _add_deprecated_data_resources(self):
self.license_table = LicenseTable(
self, 'LicenseTable', encryption_key=self.shared_encryption_key, removal_policy=RemovalPolicy.DESTROY
self, 'LicenseTable', encryption_key=self.shared_encryption_key,
removal_policy=RemovalPolicy.DESTROY
)

# These dummy exports are required until we remove dependencies from the api stack
# see https://github.com/aws/aws-cdk/issues/3414
self.export_value(self.license_table.table_name)
self.export_value(self.license_table.table_arn)

def _add_data_resources(self, removal_policy: RemovalPolicy):
self.bulk_uploads_bucket = BulkUploadsBucket(
self,
Expand Down

0 comments on commit 86ceca7

Please sign in to comment.