在pulumi脚本中,运行pulumi up
时出现以下错误
azure-native:sql:DatabaseSecurityAlertPolicy (sap_primary):
error: azure-native:sql:DatabaseSecurityAlertPolicy resource 'sap_primary' has a problem: missing required property 'resourceGroupName'
以下是代码的相关部分:
resource_group = resources.ResourceGroup(
resource_name = <rg-name>,
tags={
<tags> # placeholder for the real tags
},
opts=pulumi.ResourceOptions(import_=<rg id>))
sql_server = sql.Server(
resource_name = str(app_stage) + '-' + str(app_key) + '-sql',
resource_group_name = resource_group.name,
location = resource_group.location,
administrator_login = sql_server_admin_user,
administrator_login_password = sql_server_admin_password,
version = sql_version,
tags = resource_group.tags,
identity = sql.ResourceIdentityArgs(type=sql.IdentityType.SYSTEM_ASSIGNED)
)
sql_database_primary = sql.Database(
resource_name = sql_database_name,
resource_group_name = resource_group.name,
location = resource_group.location,
server_name = sql_server.name,
sku = sql.SkuArgs(
name = 'GP_Gen5_2',
tier = sql_edition),
zone_redundant = sql_zone_redundancy,
tags = resource_group.tags,
)
database_security_alert_policy = sql.DatabaseSecurityAlertPolicy(
resource_name = 'sap_primary',
resource_group_name = sql_server.resource_group_name,
database_name = sql_database_name,
server_name = sql_server.name,
state = sql.SecurityAlertsPolicyState.ENABLED,
)
我不明白为什么它说resourceGroupName
不见了,但正如你所看到的,它已经设置好了。我错过了什么?
为了避免出现以下问题:例如,sql_server_admin_user
来自哪里,它们在Pulumi.dev.yaml
文件中设置,并在脚本中导入,如config.get('sql_server_admin_user')
sql_server.resource_group_name
不存在。请改用resource_group.name
。