Provision using CloudFormation Create Stack

Updated 12 hours ago by Michael Cretzman

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

Ensure you have read the following topics before you add the CloudFormation Create Stack step to a Workflow:

Limitations

AWS Services Supported — Harness supports first class CloudFormation provisioning for AWS-based infrastructures:

  • SSH
  • AMI/Auto Scaling Group
  • ECS
  • Lambda

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.

Visual Summary

This topic describes steps 4 through 6 in the Harness CloudFormation Provisioning implementation process:

For step 1, see Add CloudFormation Templates. For step 2, see Map CloudFormation Infrastructure.

Here is an illustration using a deployment:

  1. The CloudFormation Create Stack step executes pre-deployment to build the infrastructure.
  2. The Infrastructure Definition is used to select the provisioned nodes.
  3. 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:

  1. In your Harness Application, click Workflows.
  2. Click Add Workflow. The Workflow dialog appears.
  3. Enter a name and description for the Workflow.
  4. In Workflow Type, select Canary.
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.
  1. In Environment, select the Environment that has the CloudFormation Provisioner set up in its Infrastructure Definitions.
  2. 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:

  1. In your Workflow, in Pre-deployment Steps, click Add Step.
  2. Select CloudFormation Create Stack, and click Next.
  3. In Provisioner, select the same Harness CloudFormation Infrastructure Provisioner you used in the Infrastructure Definition of this Workflow.
  4. In AWS Cloud Provider, typically, you will select the same Cloud Provider you used when setting up the Infrastructure Definition used by this Workflow.
You need to select an AWS Cloud Provider even if the CloudFormation Infrastructure Provisioner you selected uses a manually-entered template body. Harness needs access to the AWS API for CloudFormation via the credentials in the AWS Cloud Provider. Ensure that the AWS Cloud Provider has the credentials described in Set Up Your Harness Account for CloudFormation.
  1. In Region, select the region where you will be provisioning your resources.
  2. 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 HarnessStack-7HklGe0N6AvviJmZ.

    If you plan on using the CloudFormation Delete Stack step later in this Workflow, it is a good idea to name your stack.
  3. 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 ${serviceVariables.roleARN} or ${workflow.variables.roleArn}.
  4. In Timeout, enter how long Harness should wait for the successful CloudFormation Provisioner set up before failing the Workflow.
  5. 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.

  1. In Service, select the Harness Service to deploy.
  2. 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:
  3. 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.

Next Steps


How did we do?