简体   繁体   English

如何用文本替换 terraform 中的变量?

[英]how do i substitute text for a variable in a terraform?

I'm new to terraform and wanted to substitute the value devcert below for a variable value called env, how do i format the below to include the variable value instead of devcert?我是 terraform 的新手,想用下面的值 devcert 替换一个名为 env 的变量值,如何格式化下面的值以包含变量值而不是 devcert?

pfx_blob = data.azurerm_key_vault_secret.devcert.value pfx_blob = data.azurerm_key_vault_secret.devcert.value

You can't do that.你不能那样做。 Such operation is not supported in terraform. terraform不支持此类操作。 Instead you should use for_each to create multiple instances of azurerm_key_vault_secret , rather then fully separate data sources.相反,您应该使用for_each创建多个azurerm_key_vault_secret实例,而不是完全独立的数据源。 Then you can reference it using:然后你可以使用它来引用它:

pfx_blob = data.azurerm_key_vault_secret.devcert["myinstance"].value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Terraform - 我如何 map 不同的 azure 环境变量文件? - Terraform - How do I map different azure environment variable files? 如何在 terraform 中的给定变量下循环遍历 te - How do I loop through te below given variable in terraform 如何将管道任务中的变量传递给 terraform 任务并将其应用到我的 terraform 代码中? - How do I pass a variable from a pipeline task into a terraform task and apply it in my terraform code? 如何基于变量值运行 terraform 模块? - How do you run a terraform module based on a variable value? 如何将 Azure AD 服务主体密码导入 Terraform? - How do I import an Azure AD Service Principal Password into Terraform? 如何使用 Terraform 清除软删除的 APIM? - How Do I Purge A Soft-Deleted APIM With Terraform? 如何使 Azure 备份与 Terraform 一起工作? - How do I make the Azure backup work with Terraform? 如何将Terraform与Azure CLI和REST API相结合? - How Do I Combine Terraform With Azure CLI and REST API? 使用Terraform时如何查询2个不同的Azure目录? - How Do I Query 2 Different Azure Directories When Using Terraform? 如何使用 Terraform 部署此 ARM 模板? 请指教 - How do I deploy this ARM template with Terraform? Please Advise
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM