Provision using CloudFormation Create Stack
This topic describes how to provision infrastructure using the Workflow CloudFormation Create Stack step.
Once you have created a CloudFormation Infrastructure Provisioner and added it to a Harness Infrastructure Definition, you add that Infrastructure Definition to a Workflow.
Next, you use the CloudFormation Create Stack step in that Workflow to run the same CloudFormation template added in the Infrastructure Provisioner.
During Workflow pre-deployment, the CloudFormation Create Stack step provisions the target infrastructure.
Next, during Workflow deployment, the Workflow deploys to the provisioned infrastructure as defined in its Infrastructure Provisioner.
In this topic:
- Before You Begin
- Visual Summary
- Step 1: Add Environment to Workflow
- Step 2: Add CloudFormation Create Stack Step to Pre-deployment Steps
- Step 3: Enter Input Values
- Step 4: Add Infrastructure Definition to Phases
- Next Steps
Before You Begin
Ensure you have read the following topics before you add the CloudFormation Create Stack step to a Workflow:
- CloudFormation Provisioning with Harness
- Set Up Your Harness Account for CloudFormation
- Add CloudFormation Templates
- Map CloudFormation Infrastructure
AWS Services Supported — Harness supports first class CloudFormation provisioning for AWS-based infrastructures:
- AMI/Auto Scaling Group
Deployment Strategies Supported — For most deployments, Harness Infrastructure Provisioners are only supported in Canary and Multi-Service types. For AMI deployments, Infrastructure Provisioners are also supported in Blue/Green deployments.
This topic describes steps 4 through 6 in the Harness CloudFormation Provisioning implementation process:
Here is an illustration using a deployment:
- The CloudFormation Create Stack step executes pre-deployment to build the infrastructure.
- The Infrastructure Definition is used to select the provisioned nodes.
- The app is installed on the provisioned node.
Step 1: Add Environment to Workflow
To use a CloudFormation Provisioner in your Workflow, do the following:
- In your Harness Application, click Workflows.
- Click Add Workflow. The Workflow dialog appears.
- Enter a name and description for the Workflow.
- In Workflow Type, select Canary.
- In Environment, select the Environment that has the CloudFormation Provisioner set up in its Infrastructure Definitions.
- Click SUBMIT. The new Workflow is created.
By default, the Workflow includes a Pre-deployment Steps section. This is where you will add a step that uses your CloudFormation Provisioner.
Step 2: Add CloudFormation Create Stack Step to Pre-deployment Steps
In this step you will use the CloudFormation Create Stack step to select the same CloudFormation Infrastructure Provisioner you used in the Workflow Infrastructure Definition.
The CloudFormation Create Stack step will provision using the template in the CloudFormation Infrastructure Provisioner.
The CloudFormation Create Stack step is basically the same as the
aws cloudformation create-stack command.
The CloudFormation Create Stack step provisions your target infrastructure, and so it is added to the Pre-deployment steps in the Canary Workflow.
To add the CloudFormation Create Stack step, do the following:
- In your Workflow, in Pre-deployment Steps, click Add Step.
- Select CloudFormation Create Stack, and click Next.
- In Provisioner, select the same Harness CloudFormation Infrastructure Provisioner you used in the Infrastructure Definition of this Workflow.
- In AWS Cloud Provider, typically, you will select the same Cloud Provider you used when setting up the Infrastructure Definition used by this Workflow.
- In Region, select the region where you will be provisioning your resources.
- To name your stack, select Use Custom Stack Name and enter a name for your stack. If you do not select this option, Harness will automatically generate a unique name for your stack prefixed with
HarnessStackand the ID for your Harness Environment, such as
If you plan on using the CloudFormation Delete Stack step later in this Workflow, it is a good idea to name your stack.
- In Role ARN, enter the Amazon Resource Name (ARN) of an AWS IAM role that CloudFormation assumes to create the stack. If you don't specify a value, Harness uses the credentials you provided via AWS Cloud Provider. This allows you to tune the step for provisioning a specific AWS resource. For example, if you will only provision AWS S3, then you can use a role that is limited to S3.
You can also use Harness variable expressions in Role ARN. For example, you can create a Service or Workflow variable and then enter its expression in Role ARN, such as
- In Timeout, enter how long Harness should wait for the successful CloudFormation Provisioner set up before failing the Workflow.
- Click Next. The Input Values settings appear.
Step 3: Enter Input Values
The Input Values are automatically populated with the same variables from the CloudFormation Infrastructure Provisioner Variables section, as described in Add CloudFormation Templates.
Enter or select a value for each variable in Input Values. For encrypted text values, select an Encrypted Text secret from Harness Secrets Management.
For more information, see Use Encrypted Text Secrets.
Click Submit. The CloudFormation Create Stack step is added to your Workflow.
Now your Workflow is set up to provision an infrastructure using your CloudFormation template in the CloudFormation Infrastructure Provisioner, and then deploy to the provisioned infrastructure.
Step 4: Add Infrastructure Definition to Phases
Now that the Workflow Pre-deployment section has your CloudFormation Create Stack step added, you need to add the target Infrastructure Definition where the Workflow will deploy.
This is the same Infrastructure Definition where you mapped your CloudFormation Infrastructure Provisioner outputs, as described in Map CloudFormation Infrastructure.
For Canary Workflows, Infrastructure Definitions are added in Phases, in the Deployment Phases section.
In the Deployment Phases section, click Add Phase. The Workflow Phase settings appear.
- In Service, select the Harness Service to deploy.
- In Infrastructure Definition, select the target Infrastructure Definition where the Workflow will deploy. This is the same Infrastructure Definition where you mapped your CloudFormation Infrastructure Provisioner outputs, as described in Map CloudFormation Infrastructure.
Here is an example:
- Click Submit. Use the same Infrastructure Definition for the remaining phases in your Canary Workflow.
Once you are done, your Workflow is ready to deploy.
- The variables you use to map CloudFormation template outputs in an Infrastructure Definition can also be used in other Workflow commands. See Using CloudFormation Outputs in Workflow Steps.
- If you want to delete the stack as part of a Workflow, see Remove Provisioned Infra with CloudFormation Delete Stack.