DEV Community

Cover image for My favourite CDK parameter for large deployments is...
Gernot Glawe
Gernot Glawe

Posted on

My favourite CDK parameter for large deployments is...

Sometimes CDK Deployment takes a long time, because of the resource creation. Speaking of fsx file shares, CloudFront et.al...

A time-consuming problem

When CDK starts an Deployment it creates a CloudFormation change set and executes it immediately.

That means, you have to wait for its completion. Unless...

You tell CDK not to execute the Change Set.

An FSX Share CDK Stack

Assume we have a Stack named "fsx". An Amazon FSx might take 20 minutes to deploy.

We deploy it (half-ish) with:

cdk deploy fsx --no-execute 
Enter fullscreen mode Exit fullscreen mode

Then login into the AWS Console, to see the Changeset:

CloudFormation Change Set

The good thing is: we can check whether the resources will be added, changed or replaced, which is vital in production sets.

Do or die

Now when I start the execution, the Stack is deployed but doesn't block my terminal.

Great, but monitoring?

If I decide later I want to see the Stack log, I can use cfn-tail.

Together with awsume and cdkstat I can have a terminal dashboard if a want to monitor the deployment on multiple accounts:

while true 
do
  clear
  awsume profile1
  cdkstat
  sleep 20
  awsume profile2
  cdkstat
  sleep 20
  awsume profile3
  cdkstat
  sleep 20
done
Enter fullscreen mode Exit fullscreen mode

And the just watch the multi-account progress:

[profile1] Role credentials will expire 2021-09-13 20:30:42
Name                             Status                           Description
----                             ------                           -----------
fsx                              UPDATE_COMPLETE                  -
[profile2] Role credentials will expire 2021-09-13 19:01:13
Name                             Status                           Description
----                             ------                           -----------
fsx                              UPDATE_COMPLETE                  -
[profile3] Role credentials will expire 2021-09-13 19:01:43
Name                             Status                           Description
---------                             ------                           -----------
fsx                              UPDATE_COMPLETE                  -
Enter fullscreen mode Exit fullscreen mode

Happy watching!

Thanks

Photo by Zdeněk Macháček on Unsplash

Discussion (0)