AWS CDK obtain previous outputs of the same stack

Viewed 201

Ok, so the simple questions is: How to obtain at cdk runtime previous stack output. Say I have a stack that is going to export 1 output and I want to access this value at the beginning and generate a new one.

The broader problem is, I am trying to introduce some smart blue-green deployments. Where I read to which color current stack was deployed last time toggle the color and deploy accordingly.

Do I have to use awscli to obtain the output? I would prefer to have all logic inside cdk.

1 Answers

To the best of my knowledge, there's no way to do this after the fact within the CDK. I think your options are:

  • Use the --outputs-file option at deploy time and save the results somewhere
  • Use the Cloudformation SDK at synth/deploy time to fetch the latest value
  • As you suggested, use the AWS CLI to grab the latest value and pass it as a parameter when you invoke the CDK
Related