Comments (2)
I did get it to work by:
- using a different variable and assigning it on a per task basis to TF_WORKSPACE.
- use a TF workspace select -or-create task to create a workspace
trigger:
branches:
include:
- main
pool:
vmImage: "windows-latest"
jobs:
- job: TF_WORKSPACE_def
displayName: "TF_WORKSPACE def"
steps:
- task: TerraformInstaller@1
displayName: "Terraform_install 1.5.7"
inputs:
terraformVersion: 1.5.7
- task: TerraformTaskV4@4
displayName: "Terraform_init"
inputs:
provider: "azurerm"
command: "init"
workingDirectory: tf
backendServiceArm: "REMOVED-platform-nonprod (REMOVED)"
backendAzureRmResourceGroupName: "REMOVED-nonprod-base-infra-rg"
backendAzureRmStorageAccountName: REMOVED
backendAzureRmContainerName: tfstate-jat
backendAzureRmKey: "jr-sandbox-tf-wp"
- task: TerraformTaskV4@4
displayName: "Terraform_plan"
inputs:
workingDirectory: tf
command: plan
environmentServiceNameAzureRM: "REMOVED-platform-nonprod (REMOVED)"
- job: TF_WORKSPACE_dev
displayName: "TF_WORKSPACE dev"
dependsOn: TF_WORKSPACE_def
variables:
scope: dev
steps:
- task: TerraformInstaller@1
displayName: "Terraform_install 1.5.7"
inputs:
terraformVersion: 1.5.7
- task: TerraformTaskV4@4
displayName: "Terraform_init"
inputs:
provider: "azurerm"
command: "init"
workingDirectory: tf
backendServiceArm: "REMOVED-platform-nonprod (REMOVED)"
backendAzureRmResourceGroupName: "REMOVED-nonprod-base-infra-rg"
backendAzureRmStorageAccountName: REMOVED
backendAzureRmContainerName: tfstate-jat
backendAzureRmKey: "jr-sandbox-tf-wp"
- task: TerraformTaskV4@4
displayName: "Terraform_Workspace new|select"
inputs:
command: custom
customCommand: workspace
commandOptions: select -or-create $(scope)
workingDirectory: tf
environmentServiceNameAzureRM: "REMOVED-platform-nonprod (REMOVED)"
- task: TerraformTaskV4@4
displayName: "Terraform_plan"
inputs:
workingDirectory: tf
command: plan
environmentServiceNameAzureRM: "REMOVED-platform-nonprod (REMOVED)"
env:
TF_WORKSPACE: $(scope)
- job: TF_WORKSPACE_test
displayName: "TF_WORKSPACE test"
dependsOn: TF_WORKSPACE_dev
variables:
scope: test
steps:
- task: TerraformInstaller@1
displayName: "Terraform_install 1.5.7"
inputs:
terraformVersion: 1.5.7
- task: TerraformTaskV4@4
displayName: "Terraform_init"
inputs:
provider: "azurerm"
command: "init"
workingDirectory: tf
backendServiceArm: "REMOVED-platform-nonprod (REMOVED)"
backendAzureRmResourceGroupName: "REMOVED-nonprod-base-infra-rg"
backendAzureRmStorageAccountName: REMOVED
backendAzureRmContainerName: tfstate-jat
backendAzureRmKey: "jr-sandbox-tf-wp"
- task: TerraformTaskV4@4
displayName: "Terraform_Workspace new|select"
inputs:
command: custom
customCommand: workspace
commandOptions: select -or-create $(scope)
workingDirectory: tf
environmentServiceNameAzureRM: "REMOVED-platform-nonprod (REMOVED)"
- task: TerraformTaskV4@4
displayName: "Terraform_plan"
inputs:
workingDirectory: tf
command: plan
environmentServiceNameAzureRM: "REMOVED-platform-nonprod (REMOVED)"
env:
TF_WORKSPACE: $(scope)
However I would still like to know what is with the inconsistency of TF_WORKSPACE of creating the first workspace and not the second one when it is set as mentioned in my original post.
from azure-pipelines-terraform.
Hi sorry for late reply. Looks like you solved the issue. I will take a look on the inconsistent behavior.
from azure-pipelines-terraform.
Related Issues (20)
- Terraform Init is not compatible with Azure ARM Federated Identity service connection. HOT 6
- TerraformInstaller@1 fails on Azure pipelines with image ubuntu-latest HOT 14
- Can we Authenticate using Service principle and Certificate instead of service connection in terraform task HOT 1
- Terraform apply fails with clientCredentialsToken already expired. HOT 13
- How to enable task.debug? HOT 2
- link to Marketplace listing HOT 1
- TerraformInstaller@1 fails with ambiguous identifier HOT 4
- state command not working HOT 9
- Terraform init failure on Azure Devops Pipeline HOT 6
- Azure DevOps pipeline Terraform init fails when using service connection that is linked to an Azure AD app registration that is using workload identity federation instead of client secret HOT 3
- Error installing extension from marketplace HOT 2
- Terraform apply fails when deploying tfplan from artifactory in release pipeline HOT 2
- Terraform output failing, but not recorded as failed HOT 3
- Terraform: Unable to get latest version: using 1.1.6 HOT 2
- Azure SQL database management using Workload Identity Federation service connection in Azure DevOps HOT 4
- Allow Option to Override Subscription ID
- WIF token usage HOT 2
- Using WIF for Terraform State broken in 0.1.25 HOT 7
- Upgrade Node10 executor to Node16 HOT 2
- Allow for More Nuanced Terraform Versioning HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-pipelines-terraform.