gpt4 book ai didi

azure - 在 terraform 代码中使用多个版本的 azurerm

转载 作者:行者123 更新时间:2023-12-03 03:34:23 27 4
gpt4 key购买 nike

我有一个在模块内使用模块的 terraform 代码。

main.tf

module "FunctionApp" {
source = "../modules/FunctionApp"
location = var.location
resourceGroupName = module.rg.name
}

模块 FunctionApp - main.tf

resource "azurerm_resource_group" "example" {
name = "azure-functions-test-rg"
location = "westus2"
}
resource "azurerm_storage_account" "example" {
name = "functionsappsacostco"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "LRS"
min_tls_version = "TLS1_2"
}


resource "azurerm_app_service_plan" "example" {
name = "azure-functions-test-service-plan"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
kind = "windows"
sku {
tier = "PremiumV2"
size = "P1v2"
}
}

resource "azurerm_function_app" "example" {
name = "test-azure-functions-csco"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
version = "~4"


}
module "fz_slot" {
source = "./fz-slot"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
function_app_name = azurerm_function_app.example.name
storage_account_name = azurerm_storage_account.example.name
storage_account_access_key = azurerm_storage_account.example.primary_access_key
}

模块 fz-slot - main.tf

resource "azurerm_function_app_slot" "example" {
provider = azurerm.old
name = "staging"
location = var.location
resource_group_name = var.resource_group_name
app_service_plan_id = var.app_service_plan_id
function_app_name = var.function_app_name
storage_account_name = var.storage_account_name
storage_account_access_key = var.storage_account_access_key
version = "~4"
}

我想在除 fz-slot 模块之外的所有资源中使用最新的 azurerm 版本。在 fz-slot 模块中,我想使用 azurerm 2.67.0 版本。

我怎样才能实现这个目标?

最佳答案

你做不到。

您必须创建两个 terraform 配置,每个版本提供程序一个。

关于azure - 在 terraform 代码中使用多个版本的 azurerm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73824468/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com