Skip to content

Instantly share code, notes, and snippets.

@dustindortch
Last active February 12, 2024 14:51
Show Gist options
  • Save dustindortch/b9feec78f89ea85a5fd6d9d9741d60f1 to your computer and use it in GitHub Desktop.
Save dustindortch/b9feec78f89ea85a5fd6d9d9741d60f1 to your computer and use it in GitHub Desktop.
Terraform Best Practices: Files - Generating backend configuration in a pipeline
- name: Terraform Set Backend
id: tf-set-backend
run: |
cat > ./backend.tf << EOF
terraform {
backend "azurerm" {
container_name = "${{vars.TFSTATE_CONTAINER_NAME}}"
key = "${{vars.TFSTATE_KEY}}"
resource_group_name = "${{vars.TFSTATE_RESOURCE_GROUP_NAME}}"
storage_account_name = "${{vars.TFSTATE_STORAGE_ACCOUNT_NAME}}"
subscription_id = "${{vars.SA_SUBSCRIPTION_ID}}"
use_oidc = true
}
}
EOF
- name: Terraform Init
id: tf-init
run: terraform init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment