【发布时间】:2020-05-09 18:45:55
【问题描述】:
我的资源组已经有一些函数应用。我现在想使用 Terraform 在同一个资源组中部署更多功能应用程序。问题是当我运行 Terraform 计划时,它告诉我以前的资源将被删除,新的资源将被创建。我想保留以前的资源。我在下面复制了我的代码。 Terraform 计划的结果是创建了 5 个资源,删除了 5 个资源。
variable "resource_group_name" {
type = string
}
variable "location" {
type = string
}
variable "resource_name" {
type = string
}
resource "random_string" "random" {
length = 9
special = false
number = true
upper = false
}
variable "storage_account_tier" {
type = string
default = "Standard"
}
variable "storage_account_type" {
type = string
default = "LRS"
}
variable "service_plan_name" {
type = string
}
variable "service_plan_tier" {
type = string
default = "Standard"
}
variable "service_plan_size" {
type = string
default = "S1"
}
resource "azurerm_resource_group" "example" {
name = var.resource_group_name
location = var.location
}
resource "azurerm_storage_account" "example" {
name = replace(join(",",["storageaccount",random_string.random.result]),",","")
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = var.storage_account_tier
account_replication_type = var.storage_account_type
}
resource "azurerm_app_service_plan" "example" {
name = var.service_plan_name
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
sku {
tier = var.service_plan_tier
size = var.service_plan_size
}
}
resource "azurerm_function_app" "example" {
name = var.resource_name
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_connection_string = azurerm_storage_account.example.primary_connection_string
}
【问题讨论】:
-
计划是什么样的?您能否编辑您的问题以包含重现该问题的minimal reproducible example?
-
计划说创建了 5 个资源,删除了 5 个资源。很遗憾,我无法附上图片。
-
复制并粘贴文本到您的问题中。不要将其作为图像。
标签: azure terraform azure-function-app