From 86ceca713207cdc3e00dfbfe568af8eaf36050f2 Mon Sep 17 00:00:00 2001 From: Landon Shumway Date: Mon, 18 Nov 2024 09:50:53 -0600 Subject: [PATCH] Add dummy exports 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 https://github.com/aws/aws-cdk/pull/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. --- .../stacks/persistent_stack/__init__.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backend/compact-connect/stacks/persistent_stack/__init__.py b/backend/compact-connect/stacks/persistent_stack/__init__.py index b32a838e..bb2407f7 100644 --- a/backend/compact-connect/stacks/persistent_stack/__init__.py +++ b/backend/compact-connect/stacks/persistent_stack/__init__.py @@ -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,