terraform - Terraform 0.12 仅在条件适用时包含语句
问题描述
我试图通过添加一些语句来创建 aws_iam_policy_document 但它失败了,因为当我第一次调用它时,“arn:aws:iam::${var.account_number}:role/audit_${var.deployment_identifier”角色不存在过程:
data "aws_iam_policy_document" "kms_policy" {
statement {
sid = "Enable root access to kms key"
effect = "Allow"
principals {
type = "AWS"
identifiers = ["${var.root_role}"]
}
actions = [
"kms:Create*",
"kms:Describe*"
]
resources = ["*"]
}
statement {
sid = "Allow encryption access for specific roles"
effect = "Allow"
principals {
type = "AWS"
identifiers = "["arn:aws:iam::${var.account_number}:role/audit_${var.deployment_identifier}"]"
}
actions = [
"kms:Encrypt"
]
resources = ["*"]
}
}
问题是,我需要最后的声明,因为它需要更进一步。
首次运行此流程时如何检查角色是否存在,如果不存在则不能添加语句?
解决方案
推荐阅读
- javascript - 将参数传递给 props react-native?
- python - 如何将 API 返回的列表解析为 pandas 数据帧
- python-3.x - 使用 Matplotlib 或 Seaborn 创建感知图
- laravel - Laravel Stevebauman 位置跟踪器无法动态工作
- python - 如何用 Python 中的 original_string 替换 search_character
- git - git put all too master, force, no compare
- r - 小标题中的矩阵乘法
- angular - Firebase 不保存对象的完整数据
- discord.js - 用用户名 Discord.js 替换参数
- bash - 7z 命令的脚本化 Jenkins 管道中具有特殊字符的密码