Terraform
Create a Stack
Stacks enable you to provision and coordinate your infrastructure lifecycle at scale, offering an organized and reusable approach that expands upon infrastructure as code (IaC).
Hands-on: Try out the Deploy a Stack with HCP Terraform tutorial to get started with Stacks quickly.
This article explains how to create a Stack in HCP Terraform using a Stack’s configuration and deployment configuration files.
Requirements
Stacks are not available for users on legacy HCP Terraform team plans. Learn more about migrating to current HCP Terraform plans.
To create a Stack in HCP Terraform, you must set up the following:
- Connect a VCS provider using the Github App, GitHub OAuth workflow, or a GitLab VCS workflow.
- A repository with a top-level Stack configuration and a deployment configuration. Your Stack configuration file should include at least one
component
block, and your deployment configuration file should include at least onedeployment
block.
You must also be a member of a team in your organization with one of the following permissions:
Create a Stack
If you are creating a Stack in an organization for the first time, you should first enable Stacks for your organization. Navigate to your organization’s Settings page, and in the General settings, check the box next to Stacks to enable them.
Stacks live alongside workspaces in a project. To create a new Stack in HCP Terraform, perform the following steps:
- In the navigation menu, click Projects under Manage.
- Select the project where you want to create your Stack.
- In the project's navigation menu, select Stacks.
- Click + New stack.
- Select a version control provider from the list.
- Choose an organization and repository from the filterable list. If your repository is missing, enter its ID in the text field below the list. The list only displays the first 100 repositories from your VCS provider.
- Enter a new Stack Name.
- The name must be unique within the project and can include letters, numbers, dashes (
-
), and underscores (_
). We recommend using 90 characters or less for the name of your Stack.
- The name must be unique within the project and can include letters, numbers, dashes (
- You can optionally add a description for your Stack.
- You can optionally adjust your version control settings by expanding Advanced Options.
- Stacks automatically trigger new plans when you push them to your repositories’ default branch. You can deactivate this by toggling the VCS Trigger Enabled setting.
- You can configure Stacks to use either a branch or tag-based workflow.
- By default, HCP Terraform fetches your stack’s configuration after creating your Stack. To fetch your Stack configuration manually, uncheck Fetch configuration after HCP Terraform creates stack.
- Click Create Stack.
Next steps
After creating your Stack, you can continue to iterate on your configuration and review configuration versions or learn how to review your Stack’s deployment plans.