This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- powershell: | | |
terraform plan -var client_id="$(client_id)" -var client_secret="$(client_secret)" -var subscription_id="$(subscription_id)" -var tenant_id="$(tenant_id)" -out application.tfplan -no-color | |
workingDirectory: $(build.sourcesdirectory) | |
displayName: 'terraform plan' | |
# where $(client_id) is the appID of the service principal, | |
# $(client_secret) is the password of the service princial, | |
# $(subscription_id) is the Azure subscription to which the service principal belongs, and | |
# $(tenant_id) is the tenant value of the service principal. | |
# These values can be stored in Azure pipeline variables or as a variable group in the Azure DevOps project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- powershell: | | |
terraform init -backend-config="access_key=$(storage_access_key)" -no-color | |
workingDirectory: $(build.sourcesdirectory) | |
displayName: 'terraform init' | |
# where $(storage_access_key) is a secret variable stored in the Azure pipeline | |
# variable or a Library variable group. The value of the variable is the storage | |
# access key to the storage account where the terraform remote state file is stored |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
backend "azurerm" { | |
resource_group_name = "$(ResourceGroupToStoreTerraformBackendResources)" | |
storage_account_name = "$(UniqueStorageAccountName)" | |
container_name = "$(StorageContainerName)" | |
key = "terraform.tfstate" | |
access_key = "$(StorageAccountAccessKey)" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "VisualEditor0", | |
"Effect": "Allow", | |
"Action": [ | |
"dynamodb:PutItem", | |
"dynamodb:DeleteItem", | |
"dynamodb:GetItem" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
backend "s3" { | |
bucket = "$(BackendBucketName)" # the name of the S3 bucket that was created | |
encrypt = true | |
key = "$(PathToTFStateFile)" # the path to the terraform.tfstate file stored inside the bucket | |
region = "$(BucketRegion)" # the location of the bucket | |
dynamodb_table = "$(BackendLockTableName)" # the name of the table to store the lock | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- powershell: | | |
terraform show -no-color | |
workingDirectory: $(build.sourcesdirectory) | |
displayName: 'terraform show' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- powershell: | | |
terraform apply "application.tfplan" -no-color | |
workingDirectory: $(build.sourcesdirectory) | |
displayName: 'terraform apply' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- powershell: | | |
terraform plan -var region=$(region) -var access_key=$(access_key) -var secret_key=$(secret_key) -out application.tfplan -no-color | |
workingDirectory: $(build.sourcesdirectory) | |
displayName: 'terraform plan' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- powershell: | | |
terraform validate -json -no-color | |
workingDirectory: $(build.sourcesdirectory) | |
displayName: 'terraform validate' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Terraform extension to use this task from: | |
# https://marketplace.visualstudio.com/items?itemName=ms-devlabs.custom-terraform-tasks&ssr=false#overview | |
steps: | |
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller@0 | |
displayName: 'Install Terraform 0.14.0' | |
inputs: | |
terraformVersion: 0.14.0 | |
# Terraform versions: https://releases.hashicorp.com/terraform/ |