Using CloudFormation Outputs in Workflow Steps

Updated 1 month ago by Michael Cretzman

The variables you use to map CloudFormation template outputs in an Infrastructure Definition can also be used in other Workflow commands.

For example, if you use ${cloudformation.Region} to map a region output to the AWS region in an Infrastructure Definition, you can add a Shell Script step in your Workflow and use echo ${cloudformation.Region} to print the value.

In this topic:

Before You Begin

Visual Summary

When you use a Harness CloudFormation Infrastructure Provisioner to map template outputs to Infrastructure Definition settings, you create variable expressions and use them as parameters.

In the following example, we show:

  • Required outputs.
  • The outputs used for the optional Target Group and Application Load Balancer.
  • The stage Target Group and Application Load Balancer used for Blue/Green deployments.

As you can see, you map the CloudFormation template outputs using this syntax, where exact_name is the name of the output:

${cloudformation.exact_name}

Once defined as Infrastructure Definition parameters, these variable expressions can be used elsewhere in any Workflow that uses this Infrastructure Definition.

Step 1: Add A Workflow Step

This topic assumes you have a Workflow that uses an Infrastructure Definition that is dynamically mapped to a Harness CloudFormation Infrastructure Provisioner. For details, see Map CloudFormation Infrastructure.

Add a Workflow step where you want to use the CloudFormation template output value. Typically, this is a Shell Script step.

Step 2: Enter the Output Variable Expression

You can use any variable expression that is already used in the Infrastructure Definition in the Workflow settings.

For Canary Workflows, the Infrastructure Definition is added in the Phase settings. Therefore, you can only use the output variable expression within the Phase.

For example, let's say you use ${cloudformation.AutoScalingGroup} to map an ASG output to the ASG in an Infrastructure Definition. You can add a Shell Script step in your Workflow and use echo ${cloudformation.AutoScalingGroup} to print the value.


How did we do?