Add Terraform Cloud backend. Add/update docs @aknysh (#572)
what
- Add Terraform Cloud backend
- Add docs:
- Terraform Workspaces in Atmos
- Terraform Backends. Describes how to configure backends for AWS S3, Azure Blob Storage, Google Cloud Storage, and Terraform Cloud
why
- Allow configuring and using the Terraform Cloud backend
- Document existing and new Atmos features
docs
Terraform Cloud backend uses a cloud
block to specify which organization and workspace(s) to use.
To configure the Terraform Cloud backend in Atmos, add the following config to an Atmos manifest in _defaults.yaml
:
terraform:
backend_type: cloud
backend:
cloud:
organization: "my-org"
hostname: "app.terraform.io"
workspaces:
# Parameters for workspaces
For each component, you can optionally specify the workspaces.name
parameter similar to the following:
components:
terraform:
my-component:
# Optional backend configuration for the component
backend:
cloud:
workspaces:
name: "my-component-workspace"
If auto_generate_backend_file
is set to true
in the atmos.yaml
CLI config file in the components.terraform
section,
Atmos will deep-merge the backend configurations from the _defaults.yaml
manifests and from the component itself, and will generate a backend config JSON file backend.tf.json
in the component's folder, similar to the following example:
{
"terraform": {
"cloud": {
"hostname": "app.terraform.io",
"organization": "my-org",
"workspaces": {
"name": "my-component-workspace"
}
}
}
}
Instead of specifying the workspaces.name
parameter for each component in the component manifests, you can use
the {terraform_workspace}
token in the cloud
backend config in the _defaults.yaml
manifest.
The token {terraform_workspace}
will be automatically replaced by Atmos with the Terraform workspace for each component. This will make the entire configuration DRY.
terraform:
backend_type: cloud
backend:
cloud:
organization: "my-org"
hostname: "app.terraform.io"
workspaces:
# The token `{terraform_workspace}` will be automatically replaced with the
# Terraform workspace for each Atmos component
name: "{terraform_workspace}"