Skip to content

Instantly share code, notes, and snippets.

Last active Apr 3, 2021
What would you like to do?
Using powershell in azure-pipelins.yaml for terraform init
- powershell: |
terraform init -backend-config="bucket=skundu-terraform-remote-state" -backend-config="key=tf/ADO-TF-VPC-Int/terraform.tfstate" -backend-config="region=$(region)" -backend-config="access_key=$(access_key)" -backend-config="secret_key=$(secret_key)" -no-color
workingDirectory: $(build.sourcesdirectory)
displayName: 'terraform init'
Copy link

kunduso commented Apr 3, 2021

The above is an example of a "terraform init" command where the remote state is stored in a bucket named "skundu-terraform-remote-state" and inside the bucket the terraform.tfstate file is nested two folders (tf/ADO-TF-VPC-Int/) deep relative to the bucket.
The $(region) value is the region of the bucket and $(access_key) is the access key and $(secret_key) is the secret key respectively of the IAM user that Terraform is going to run as.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment