You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all. Like most of us, I have a multi-stack deployment with cross-stack dependencies. I often find myself encountering dependency deadlock. This is especially frequent during early development of infrastructure. This occurs due to the following scenario
StackA exposes myProperty
StackB references stackA.myProperty which results in StackA including a CfnExport in the template
StackB later removes the reference to stackA.myProperty.
cdk recognizes that StackA no longer needs the export and removes the CfnExport for myProperty
deployment of StackA fails due to CloudFormation error stating that the CfnExport 'cannot be deleted as it is in use by StackB'.
While it may seem obvious to just deploy StackB, typically StackA is something like a NetworkStack while StackB is Persistence or Compute. StackA likely contains changes which need to be deployed prior to StackB. The guidance in the CDK documentation is to temporarily add a CfnOutput until the dependency. But, is there a reason why CDK can't do this for us?
ie) Mark Outputs that will be removed as CDK_TEMP_MIGRATE
Compare the list of the CfnOutput's for the currently deployed stack to the one's in the ChangeSet to be deployed
If CfnOutput's exist in the deployed stack but do not in the ChangeSet (are being removed), add them to the ChangeSet with a description of CDK_TEMP_MIGRATE
Deploy
Remove CDK_TEMP_MIGRATE Outputs on subsequent deployment
Compare the list of the CfnOutput's for the currently deployed stack to the one's in the ChangeSet to be deployed
If the status of the deployed stack is UPDATE_COMPLETE|CREATE_COMPLETE (previous deployment success)
ignore deployed CfnOutputs which have a description of CDK_TEMP_MIGRATE as those were part
of a previous Output migration and it's assumed that dependent stacks have already been deployed and the dependency deadlock resolved (they no longer need to be deployed)
If there are remaining CfnOutput's which exist in the deployed stack but not in the proposed ChangeSet, add them to the ChangeSet with a description of CDK_TEMP_MIGRATE
Deploy
This would not solve for scenarios where a stack is deployed, Outputs are marked as CDK_TEMP_MIGRATE, and then the stack redeployed prior to its dependent stacks. You would need to manually add CfnOutput's as is suggested today to resolve the deadlock. This would however solve dependency issues for those of us which have CICD that updates all stacks on each deployment.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all. Like most of us, I have a multi-stack deployment with cross-stack dependencies. I often find myself encountering dependency deadlock. This is especially frequent during early development of infrastructure. This occurs due to the following scenario
StackA
exposesmyProperty
StackB
referencesstackA.myProperty
which results inStackA
including aCfnExport
in the templateStackB
later removes the reference tostackA.myProperty
.StackA
no longer needs the export and removes theCfnExport
formyProperty
StackA
fails due to CloudFormation error stating that theCfnExport
'cannot be deleted as it is in use by StackB'.While it may seem obvious to just deploy
StackB
, typicallyStackA
is something like a NetworkStack whileStackB
is Persistence or Compute.StackA
likely contains changes which need to be deployed prior toStackB
. The guidance in the CDK documentation is to temporarily add aCfnOutput
until the dependency. But, is there a reason why CDK can't do this for us?ie)
Mark Outputs that will be removed as
CDK_TEMP_MIGRATE
CfnOutput's
for the currently deployed stack to the one's in theChangeSet
to be deployedCfnOutput's
exist in the deployed stack but do not in the ChangeSet (are being removed), add them to the ChangeSet with a description ofCDK_TEMP_MIGRATE
Remove
CDK_TEMP_MIGRATE
Outputs on subsequent deploymentCfnOutput's
for the currently deployed stack to the one's in the ChangeSet to be deployedUPDATE_COMPLETE|CREATE_COMPLETE
(previous deployment success)CDK_TEMP_MIGRATE
as those were partof a previous Output migration and it's assumed that dependent stacks have already been deployed and the dependency deadlock resolved (they no longer need to be deployed)
CfnOutput's
which exist in the deployed stack but not in the proposed ChangeSet, add them to the ChangeSet with a description ofCDK_TEMP_MIGRATE
This would not solve for scenarios where a stack is deployed, Outputs are marked as
CDK_TEMP_MIGRATE
, and then the stack redeployed prior to its dependent stacks. You would need to manually addCfnOutput's
as is suggested today to resolve the deadlock. This would however solve dependency issues for those of us which have CICD that updates all stacks on each deployment.Beta Was this translation helpful? Give feedback.
All reactions