Skip to content

Instantly share code, notes, and snippets.

@kunduso
Last active April 3, 2021 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunduso/4816eeecabb7c81553dec939b204119f to your computer and use it in GitHub Desktop.
Save kunduso/4816eeecabb7c81553dec939b204119f to your computer and use it in GitHub Desktop.
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'
@kunduso
Copy link
Author

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