我想使用一个资源/模块的输出变量作为另一资源/模块的输入。那可能吗?在这里,我希望根目录中“outputs.tf”的输出值用作模块“main.tf”中的输入。
root
|--main.tf
|--vars.tf
|--outputs.tf
|---module
|--main.tf
|--vars.tf
Run Code Online (Sandbox Code Playgroud) 我无法找到一种方法来通过 terraform 使用私有 IP 创建应用程序网关,而无需手动插入硬编码的 IP 私有地址。
我试过:
仅当使用硬编码 IP 地址创建应用程序网关时,它才有效。
这个解决方案对我来说还不够好,因为我们处理许多环境,并且我们不想让开发人员记住添加私有 IP。
有好的解决办法吗?
terraform azure-application-gateway terraform-provider-azure
我计划通过 Terraform 管理 Azure 资源锁。ReadOnly我的想法是在资源级别创建锁。根据 Terraform 文档,以下代码可用于此目的。
resource "azurerm_management_lock" "resource-group-level" {
name = "resource-group-level"
scope = azurerm_resource_group.example.id
lock_level = "ReadOnly"
notes = "This Resource Group is Read-Only"
}
Run Code Online (Sandbox Code Playgroud)
现在我担心对该资源的任何后续修改。在下一个执行周期中,对资源的任何更改都将失败,因为ReadOnly资源上有锁。我希望删除锁,进行修改并重新添加锁。
如何通过 Terraform 处理这样的场景?
azure terraform terraform-provider-azure azure-resource-lock
我收到以下错误
\n\xe2\x94\x82 Error: Plugin error\n\xe2\x94\x82\n\xe2\x94\x82 with provider["registry.terraform.io/hashicorp/azurerm"],\n\xe2\x94\x82 on nsg.tf line 13, in provider "azurerm":\n\xe2\x94\x82 13: provider "azurerm" {\n\xe2\x94\x82\n\xe2\x94\x82 The plugin returned an unexpected error from plugin.(*GRPCProvider).ConfigureProvider: rpc error: code = Internal desc = grpc: error while marshaling: string field\n\xe2\x94\x82 contains invalid UTF-8\nRun Code Online (Sandbox Code Playgroud)\n当我尝试对以下代码执行 Terraform 计划时
\n# Configure the Microsoft Azure Provider\nterraform {\n required_providers {\n azurerm = {\n source = "hashicorp/azurerm"\n version = "=2.74.0"\n }\n }\n}\n\n# Configure the Microsoft Azure Provider\nprovider "azurerm" {\n features {}\n}\nresource "azurerm_network_security_group" "nsg" {\n …Run Code Online (Sandbox Code Playgroud) 作为 IaC 的一部分,函数应用程序(我们将其命名为FuncAppX)是使用 Terraform 进行部署的,其中包含一个函数。
我需要使用 Terraform 在函数应用程序中访问同一函数的Url 。我在这里分享相同的屏幕截图以供参考,其中很容易获得“ GetFunction Url ”,但使用 terraform ,我没有办法返回相同的屏幕截图,它需要作为输入传递给另一个函数应用程序。
terraform azure-functions terraform-provider-azure infrastructure-as-code
与状态文件有何terraform plan关系。destroy
当 Terraform 执行时plan,
它如何知道清单文件中的所需状态与 azure 门户中资源的当前状态相同?是直接使用azurerm api检查还是参考状态文件?
如果它引用状态文件,那么 terraform 计划如何在第一次计划时得到验证,而它还没有状态文件(因为它只是一个terraform apply会生成状态文件的文件?
其次,该terraform destroy命令是否引用了我们的清单文件(所需的配置文件),或者只是用当前状态(Azure 门户中的资源实际状态)验证状态文件
如何有条件地跳过使用 terraform 创建/实现的部分 terraform 资源?
# main.tf file
locals {
vnet_type = (var.vnet_type != "" ? var.vnet_type : "None")
}
data "azurerm_virtual_network" vnet {
name = "testvnet"
resource_group_name = "rest1"
}
data "azurerm_subnet" subnets {
name = "testSubnet"
resource_group_name = "rest1"
virtual_network_name = data.azurerm_virtual_network.vnet.name
}
resource "azurerm_api_management" "apim_demo" {
name = "test-apim"
location = "East US"
resource_group_name = "rest1"
publisher_name = "admin"
publisher_email = "admin@gmail.com"
sku_name = "Developer_1"
identity {
type = "SystemAssigned"
}
# vnet_Type can be External, None …Run Code Online (Sandbox Code Playgroud) 我是地形新手。我正在尝试通过天蓝色管道创建一个简单的存储帐户,但是当我运行管道时,出现错误“命令行参数太多”。我很震惊,我不知道我做错了什么。有人可以帮忙吗?
\n这是我的计划脚本:
\n- script:\n terraform plan -out = plan.tfplan \n displayName: Terraform plan\n workingDirectory: $(System.DefaultWorkingDirectory)/terraform\n env:\n ARM_CLIENT_ID: $(application_id)\n ARM_CLIENT_SECRET: $(client_secret)\n ARM_TENANT_ID: $(tenant_id)\n ARM_SUBSCRIPTION_ID: $(subscription_id)\n TF_VAR_client_id: $(application_id) \n TF_VAR_tenant_id: $(tenant_id) \n TF_VAR_subscription_id: $(subscription_id) \n TF_VAR_client_secret: $(client_secretRun Code Online (Sandbox Code Playgroud)\r\n我收到的错误:
\nStarting: Terraform plan\n\nGenerating script.\nScript contents:\nterraform plan -out = plan.tfplan\n========================== Starting Command Output ===========================\n/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/3d07140f-ec17-4bfc-9384-a1170fae1248.sh\n\xe2\x95\xb7\n\xe2\x94\x82 Error: Too many command line arguments\n\xe2\x94\x82 \n\xe2\x94\x82 To specify a working directory for the plan, use the …Run Code Online (Sandbox Code Playgroud)例如,根据Drupal 的 helm 图表文档,默认值 isaccessModes转换["ReadWriteOnce"]为 YAML 中的以下内容:
...
accessModes
- ReadWriteOnce
Run Code Online (Sandbox Code Playgroud)
使用 Terraform helm_release资源时,以下内容不起作用,并且 yaml 文件始终显示上面的默认值:
set {
name = "persistence.accessModes"
value = "ReadWriteMany"
}
Run Code Online (Sandbox Code Playgroud)
set {
name = "persistence.accessModes"
value = "[\"ReadWriteMany\"]"
}
Run Code Online (Sandbox Code Playgroud)
set {
name = "persistence.accessModes"
value = "- ReadWriteMany"
}
Run Code Online (Sandbox Code Playgroud) 我在一个应用程序服务计划中包含三个网络应用程序。一个应用程序是前端,另一个是 API,第三个是功能应用程序。所有这些都包含在 Linux 应用服务计划中。
我在这三个应用程序中有很多应用程序配置设置。我注意到的是,如果我输入:
lifecycle {
ignore_changes = [
"auth_settings",
"app_settings"
]
}
Run Code Online (Sandbox Code Playgroud)
每次应用后,terraform 都会继续从其中一个应用程序重写应用程序配置。如果我注释掉其中一个应用程序的 app_settings 以重新部署应用程序配置,则另一个应用程序将被清除。
这是 Terraform 中的错误还是其他问题?我正在使用 AzureRM 提供程序 2.0
代码如下所示:
module "name_app_service_plan" {
version = "~> 3.0"
source = "contoso.com/names/azurerm"
providers = { azurerm = azurerm, random = random }
resource_environment = var.project.environment.name
resource_location = var.location
resource_name = var.project.name
}
module "name_app_service_api" {
version = "~> 3.0"
source = "contoso.com/names/azurerm"
providers = { azurerm = azurerm, random = random }
resource_environment = var.project.environment.name
resource_location = …Run Code Online (Sandbox Code Playgroud) azure terraform azure-web-app-service terraform-provider-azure