我试图在aws_iam_policy_document语句的resources块中创建一个循环。
我有一个本地变量accounts_to_protect,它是亚马逊网络服务的账户ID列表
locals {
accounts_to_protect = tolist(setsubtract(var.all_accounts, var.blocked_accounts))
}目前,我只使用我的列表的第一个索引
resources = [
"arn:aws:ec2::${local.accounts_to_protect.0}:*"
]我不知道如何在资源块中迭代它。我试图添加一个for,但似乎不起作用。我想有一个每个帐户id的资源arn。
发布于 2021-10-22 00:23:51
一种可能的解决方案已经在评论中了。第二个问题是:
resources = [for account in local.accounts_to_protect: "arn:aws:ec2::${account}:*"]https://stackoverflow.com/questions/69659319
复制相似问题