遇到一个问题,我有一个空资源,该资源运行脚本来创建一段配置。整个 TF 需要在帐户的每个区域中运行,因此我已将所有内容设置为使用区域作为变量。
这导致 terraform 在区域 2 中创建新配置之前销毁区域 1 中的原始空资源配置。其他 terraform 资源仅在区域 2 中创建新资源,并将区域 1 中的资源保留在原处。有没有办法让空资源的行为与其他资源相同?
resource "null_resource" "config-s3-remediation" {
triggers = {
account_name = var.account_name
region = var.region
}
depends_on = [
aws_config_config_rule.s3_access_logging_rule,
aws_ssm_document.s3_access_logging_ssm
]
provisioner "local-exec" {
command = "python3 ${path.module}/remediation_config.py add ${self.triggers.region}
}
provisioner "local-exec" {
when = destroy
command = "python3 ${path.module}/remediation_config.py remove ${self.triggers.region}"
}
}
Run Code Online (Sandbox Code Playgroud) terraform ×1