Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uruchamianie Terraform w Azure DevOps
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.Repository.LocalPath)/src'
ArtifactName: 'drop'
publishLocation: 'Container'
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-installer-task.TerraformInstaller@0
displayName: 'Install Terraform'
inputs:
terraformVersion: 1.1.7
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = ">= 2.63"
}
}
backend "azurerm" {
}
required_version = ">= 0.14.9"
}
terraform {
backend "azurerm" {
resource_group_name = "StorageAccount-ResourceGroup"
storage_account_name = "tfstates"
container_name = "tfstates"
key = "prod.tfstate"
}
}
steps:
- task: qetza.replacetokens.replacetokens-task.replacetokens@4
displayName: 'Replace tokens in **/*.tf'
inputs:
rootDirectory: '$(System.DefaultWorkingDirectory)/_TerraformAzure/drop'
targetFiles: '**/*.tf'
tokenPattern: rm
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV2@2
displayName: 'Terraform : azurerm validate and apply'
inputs:
command: apply
workingDirectory: '$(System.DefaultWorkingDirectory)/_TerraformAzure/drop'
commandOptions: '-auto-approve'
environmentServiceNameAzureRM: 'Subskrypcja platformy Azure'
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV2@2
displayName: 'Terraform : azurerm init'
inputs:
workingDirectory: '$(System.DefaultWorkingDirectory)/_TerraformAzure/drop'
backendServiceArm: 'Subskrypcja platformy Azure'
backendAzureRmResourceGroupName: 'terraform-config'
backendAzureRmStorageAccountName: plawgoterraformazured
backendAzureRmContainerName: terraform
backendAzureRmKey: test.ftstate
variable "env" {
type = string
default = "__env__"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment