我正在尝试使用azurerm_postgresql_server
资源块在Azure上创建Postgres服务器。我将azurerm
版本固定为2.4.0,这意味着我应该是最新的,可以使用documentation中的示例。取而代之的是,我丢失了必需的参数错误,并且看到消息指的是缺少的属性,根据文档,这些属性已被弃用。
到目前为止,我已经尝试过运行terraform init -upgrade
,以防万一我以前尝试使用较旧版本的提供程序来创建Postgres,并且它导致了插件的缓存版本,但是没有任何效果。我不知道出了什么问题-是代码本身还是机器上的terraform设置。下面是简化的代码段和错误输出,谢谢!
provider "azurerm" {
version = "=2.4.0"
subscription_id = "xxxxxxxxxxxxxxx"
features {
key_vault {
purge_soft_delete_on_destroy = true
}
}
}
resource "azurerm_postgresql_server" "postgres" {
name = "sarum-hymnal-postgresql-server"
location = var.resource_group.location
resource_group_name = var.resource_group.name
sku_name = "B_Gen4_1"
storage_mb = 5120
backup_retention_days = 7
geo_redundant_backup_enabled = false
auto_grow_enabled = false
administrator_login = data.azurerm_key_vault_secret.POSTGRES-USERNAME.value
administrator_login_password = data.azurerm_key_vault_secret.POSTGRES-SECRET.value
version = "11"
ssl_enforcement_enabled = true
tags = var.resource_group.tags
}
Error: Missing required argument
on sarum-hymnal/main.tf line 26, in resource "azurerm_postgresql_server" "postgres":
26: resource "azurerm_postgresql_server" "postgres" {
The argument "ssl_enforcement" is required, but no definition was found.
Error: Unsupported argument
on sarum-hymnal/main.tf line 31, in resource "azurerm_postgresql_server" "postgres":
31: storage_mb = 5120
An argument named "storage_mb" is not expected here.
通过在根目录上运行terraform providers
,我得到以下输出:
.
├── provider.azurerm =2.4.0
├── module.early-modern-ballot
│ └── provider.azurerm (inherited)
├── module.hands-on-reading
│ └── provider.azurerm (inherited)
├── module.poetic-transformations
│ └── provider.azurerm (inherited)
├── module.sarum-hymnal
│ └── provider.azurerm (inherited)
├── module.soundscapes-of-text
│ └── provider.azurerm (inherited)
└── module.translations
└── provider.azurerm (inherited)
答案 0 :(得分:3)
您可以将Terraform版本升级到v0.12
,将azurerm
提供程序的版本升级到version = ">=2.7"
。这对我有效。
有关更多详细信息,请参见v2.0 of the AzureRM Provider和Upgrading to Terraform v0.12。