CloudFormation provisioning
Provision AWS infrastructure using CloudFormation templates in Harness.
Harness supports AWS CloudFormation as an infrastructure provisioner. You can use CloudFormation templates to provision AWS resources as part of your deployment process.
Harness can provision any AWS resource that is supported by CloudFormation. You can use CloudFormation to provision infrastructure for deployments or to provision any AWS resources on demand.
What you will learn from this topic
How to understand the supported deployment types and provisioning modes for CloudFormation provisioning.
How to choose between ad hoc provisioning and dynamic provisioning for CloudFormation.
How to configure complete pipeline examples for both ad hoc and dynamic provisioning modes.
Supported deployment types and modes
Harness CloudFormation provisioning is supported in the following deployment types:
Basic
Canary
Blue-Green
Harness can provision any AWS resource that is supported by CloudFormation.
CloudFormation templates must be in JSON or YAML format.
Before you begin
Harness project access: View, Create/Edit, and Execute permissions on Pipelines, Environments, and Infrastructure Definitions. For more information, refer to RBAC in Harness to configure roles.
AWS connector: A Harness AWS connector with permissions to provision resources in your target AWS account. For more information, refer to AWS connector settings reference to configure the connector and review required AWS IAM roles for CloudFormation provisioning.
Harness Delegate: A delegate installed in an environment that can connect to AWS. For more information, refer to Delegate installation overview to install a delegate.
CloudFormation template: A JSON or YAML CloudFormation template that defines the AWS resources to provision.
Provisioning modes
Harness supports two CloudFormation provisioning modes:
Ad hoc provisioning: Provision infrastructure as a standalone task without deploying an application in the same flow.
Dynamic provisioning: Provision the target infrastructure and deploy your application to it in the same stage.
The pipeline steps are configured the same way for both modes. Choose the mode that matches your goal: use ad hoc provisioning to manage infrastructure on its own, and dynamic provisioning to provision and deploy in one stage.
For more information, refer to Provisioning overview to understand Harness provisioning concepts and use cases.
Ad hoc provisioning
Ad hoc provisioning lets you provision infrastructure as a standalone workflow without deploying an application in the same flow. This mode is useful to create test environments, set up shared resources, or make infrastructure changes independently of application deployments.
For ad hoc provisioning, add the CloudFormation Create Stack step to the Execution section of a CD Deploy stage. The step provisions your resources when the stage runs.
Example use cases:
Provision a shared AWS VPC, subnets, and security groups that other pipelines consume.
Stand up a temporary test environment for validation, then destroy it in a later step.
Run a one-time infrastructure change defined in a CloudFormation template.
Dynamic provisioning
For dynamic provisioning, add the CloudFormation Create Stack step to the Environment section of a CD Deploy stage and map the CloudFormation stack outputs to the Infrastructure Definition. Harness then deploys your application to the provisioned infrastructure in the same stage.
Example use cases:
Provision an AWS EC2 instance and deploy your application to it in a single pipeline.
Create ephemeral AWS resources per pull request, deploy to them, and tear them down afterward.
For detailed steps on configuring dynamic provisioning, refer to Provision target deployment infrastructure dynamically with CloudFormation.
CloudFormation steps
Harness provides the following CloudFormation steps for your CD pipelines:
CloudFormation Create Stack: Provisions AWS resources using a CloudFormation template. For more information, refer to Provision with the CloudFormation Create Stack step.
CloudFormation Delete Stack: Deletes a CloudFormation stack to clean up provisioned resources. For more information, refer to Remove provisioned infrastructure with the CloudFormation Delete step.
CloudFormation Rollback Stack: Rolls back a CloudFormation stack to the last successfully provisioned version. For more information, refer to Rollback provisioned infrastructure with the CloudFormation Rollback step.
Pipeline examples
The following examples show complete pipeline YAML for ad hoc provisioning and dynamic provisioning using CloudFormation.
Ad hoc provisioning example
This example provisions infrastructure using CloudFormation without deploying an application. The CloudFormation Create Stack step is in the Execution section of the stage.
Dynamic provisioning example
This example provisions infrastructure using CloudFormation in the Environment section. CloudFormation stack outputs are accessible in execution steps. The application is then deployed to the provisioned infrastructure in the Execution section.
Next steps
Provision target deployment infrastructure dynamically with CloudFormation: Configure dynamic provisioning to create infrastructure at runtime.
Kubernetes deployments: Deploy applications to Kubernetes infrastructure provisioned with CloudFormation.
Provisioning overview: Understand Harness provisioning concepts across all cloud providers.
Last updated
Was this helpful?