[英]Unable to select Terraform workspace in Azure Devops pipeline
I am trying to deploy infrastructure in AWS using Azure Devops.我正在尝试使用 Azure Devops 在 AWS 中部署基础设施。 I have a pipeline to deploy the infra into separate environments using Terraform.
我有一个管道可以使用 Terraform 将基础设施部署到单独的环境中。 Using Terraform workspaces is how I have the back end infra being managed.
使用 Terraform 工作区是我管理后端基础设施的方式。 I am getting an error selecting a workspace after initializing Terraform.
初始化 Terraform 后选择工作区时出现错误。 Below is my
azure-pipelines.yml
file.下面是我的
azure-pipelines.yml
文件。 I am utilizing the built in Tasks integration to integrate the steps for Terraform deployment.我正在利用内置的任务集成来集成 Terraform 部署的步骤。 Any advice on how to structure the pipeline to get past this error would be helpful.
有关如何构建管道以克服此错误的任何建议都会有所帮助。
azure-pipelines.yml天蓝色管道.yml
trigger:
- master
pool:
vmImage: ubuntu-20.04
stages:
- stage: TerraformInstall
displayName: Terraform
jobs:
- job: InstallTerraform
displayName: Install Terraform
steps:
- task: charleszipp.azure-pipelines-tasks-terraform.azure-pipelines-tasks-terraform-installer.TerraformInstaller@0
- stage: Init
displayName: Init
jobs:
- job: init
displayName: Terraform init
steps:
- task: TerraformTaskV3@3
inputs:
provider: 'aws'
command: 'init'
- stage: DevStaging
displayName: Push to Development / Staging
jobs:
- job: devstage
displayName: Push to DevStaging
steps:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV3@3
inputs:
provider: aws
command: custom
customCommand: 'workspace select devstage'
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV3@3
inputs:
provider: aws
command: apply
commandOptions: '-var-file=devstage.tfvars -auto-approve'
Error错误
All other commands:
console Try Terraform expressions at an interactive command prompt
fmt Reformat your configuration in the standard style
force-unlock Release a stuck lock on the current workspace
get Install or upgrade remote Terraform modules
graph Generate a Graphviz graph of the steps in an operation
import Associate existing infrastructure with a Terraform resource
login Obtain and save credentials for a remote host
logout Remove locally-stored credentials for a remote host
output Show output values from your root module
providers Show the providers required for this configuration
refresh Update the state to match remote systems
show Show the current state or a saved plan
state Advanced state management
taint Mark a resource instance as not fully functional
test Experimental support for module integration testing
untaint Remove the 'tainted' state from a resource instance
version Show the current Terraform version
workspace Workspace management
Global options (use these before the subcommand, if any):
-chdir=DIR Switch to a different working directory before executing the
given subcommand.
-help Show this help output, or the help for a specified subcommand.
-version An alias for the "version" subcommand.
##[error]Error: The process '/usr/local/bin/terraform' failed with exit code 127
Finishing: TerraformTaskV3
customCommand field only takes one keyword. customCommand 字段只需要一个关键字。 in this case it would be 'workspace' 'select devstage' sholud be in the commandOptions
在这种情况下,它应该是 'workspace' 'select devstage' 应该在 commandOptions 中
example:例子:
- task: ms-devlabs.custom-terraform-tasks.custom-terraform-release-task.TerraformTaskV3@3
inputs:
provider: aws
command: custom
customCommand: 'workspace'
commandOptions: 'select devstage'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.