Skip to main content

Using CloudFormation Outputs in Workflow Steps

This content is for Harness FirstGen. Switch to NextGen.The CloudFormation output variables you use to map CloudFormation template outputs in an Infrastructure Definition can also be output 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:


Once these variable expressions are defined as Infrastructure Definition parameters, and used by the CloudFormation Create Stack step in a Workflow, they can be used elsewhere in the Workflow.

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, and a CloudFormation Create Stack step in the Workflow that provisions that infrastructure.

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.