Azure Pipelines地形初始化-后端配置抛出退出代码127



有一个用于地形规划和部署的简单管道

通过模板在我的管道中运行terraform init时出现错误(退出代码127(

这是保存初始化步骤的模板

steps:
- task: Bash@3
displayName: 'Terraform Init'
env:
ARM_CLIENT_ID: $(AZURE_CLIENT_ID)
ARM_CLIENT_SECRET: $(AZURE_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
ARM_TENANT_ID: $(AZURE_TENANT_ID)
inputs:
targetType: 'inline'
workingDirectory: $(System.DefaultWorkingDirectory)
script: |
set -euo pipefail

echo "Initialize"
terraform init 
-input=false 
-backend-config="resource_group_name=${TF_STORAGE_RG}"  
-backend-config="storage_account_name=${TF_STORAGE_ACCOUNT}" 
-backend-config="container_name=${TF_STORAGE_BLOB_CONTAINER}" 
-backend-config="key=${TF_STORAGE_BLOB_NAME}" 


terraform validate


terraform -v
terraform providers

我将值存储在可访问管道的变量组中

但是我得到错误

Terraform initialized in an empty directory!
The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.
/home/vsts/work/_temp/d3a0a3ba-04aa-4b39-8c4a-78045790fbe4.sh: line 8: -backend-config=storage_account_name="statebucket": command not found
##[error]Bash exited with code '127'.
Finishing: Terraform Init

很难理解为什么它向我抛出了一个"未找到命令"的错误。有什么想法吗?

在""在${TF_STORAGE_RG}之后。参见下面-如果我运行sed来删除行末尾的空格;命令未找到";错误消失了。我得到了一个不同的错误,但那是一个不同问题。

$ cat doit.sh
export TF_STORAGE_RG=a
export TF_STORAGE_ACCOUNT=b
export TF_STORAGE_BLOB_CONTAINER=c
export TF_STORAGE_BLOB_NAME=d
terraform init 
-input=false 
-backend-config="resource_group_name=${TF_STORAGE_RG}" 
-backend-config="storage_account_name=${TF_STORAGE_ACCOUNT}" 
-backend-config="container_name=${TF_STORAGE_BLOB_CONTAINER}" 
-backend-config="key=${TF_STORAGE_BLOB_NAME}"
$ ./doit.sh
Too many command line arguments. Did you mean to use -chdir?
./doit.sh: line 10: -backend-config=storage_account_name=b: command not found
$ sed -i 's/ $//g' doit.sh
$ ./doit.sh
Initializing the backend...
╷
│ Error: Failed to get existing workspaces: Error retrieving keys for Storage Account "b": storage.AccountsClient#ListKeys: Invalid input: autorest/validation: validation failed: parameter=accountName constraint=MinLength value="b" details: value length must be greater than or equal to 3

最新更新