我创建了一个简单的管道。带有 Azure DevOps构建管道的 Github 存储库。
我在 Github 私有存储库中的 ax.tf 文件中定义了以下提到的变量:
ARM_CLIENT_ID
ARM_CLIENT_SECRET
ARM_SUBSCRIPTION_ID
ARM_TENANT_ID
构建管道有一个简单的命令行作业,如下所示:
sudo apt install wget
wget https://releases.hashicorp.com/terraform/0.11.11/terraform_0.11.11_linux_amd64.zip
sudo apt-get install unzip
unzip terraform_0.11.11_linux_amd64.zip
terraform init
terraform plan -var-file=terraform.tfvars -out=ax.plan
terraform apply ax.plan
terraform destroy -auto-approve
我想知道如何在 Terraform ax.tf 文件中引用这些构建变量?
根据 Azure DevOps 文档,我已经完成了类似下面的操作,但它不起作用:
variable "ARM_SUBSCRIPTION_ID" {
default="$(Build.ARM_SUBSCRIPTION_ID)"
}
不幸的是,它没有按预期工作,它在以下执行级别停止:
[0m[1m[32mTerraform has been successfully initialized![0m[32m[0m
[0m[32m
You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.
If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.[0m
[0m[1mvar.ARM_CLIENT_ID[0m
任何帮助将不胜感激。
谢谢你。