Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS CDK - post deployment actions

is anyone aware of a method to execute post-deploy functionality. Follwing is a sample of a casual CDK app.

app = core.App()
Stack(app, ...)
app.synth()

What I am looking for is a way to apply some logic after template is deployed. The thing is the app completes before cdk tool starts deploying template.

thanks

like image 390
Łukasz Avatar asked Jul 01 '19 12:07

Łukasz


1 Answers

Edit: CDK now has https://github.com/cdklabs/cdk-triggers, which allows calling Lambda functions before/after resource/stack creation


You can't do that from CDK at the moment. See https://github.com/awslabs/aws-cdk/issues/2849. Maybe add your +1 there, let them know you'd like to see this feature.

What you can do is wrap cdk deploy in a shell script that will run whatever you need after the CDK is done. Something like:

#!/bin/sh

cdk deploy "$@"
success=$?
if [ $success != 0 ]; then
    exit $success
fi

run_post_deploy_with_arguments.sh "$@"

will run deploy with the given arguments, then call a shell scripts passing it the same arguments if deployment was successful. This is a very crude example.

like image 68
bgdnlp Avatar answered Oct 02 '22 13:10

bgdnlp