【发布时间】:2018-10-19 22:21:05
【问题描述】:
我想使用 terraform 创建一个 aws_iam_role,但在运行 terraform apply后,我收到以下错误消息:
aws_iam_role.role: Error Updating IAM Role (edb_eb_role) Assume Role Policy: MalformedPolicyDocument: Has prohibited field Resource
这是我的政策:
resource "aws_iam_role" "role" {
name = "edb_eb_role"
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
},
{
"Action": [
"logs:*"
],
"Effect": "Allow",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": [
"*"
]
}
]
}
EOF
}
我做错了什么?我也尝试只对 Principals 执行此操作,但随后我收到消息说“Principals”也不被禁止?
【问题讨论】:
-
AssumeRole 不能直接拥有策略。您需要使用 aws_iam_role_policy_attachment 步骤来执行此操作。
-
提供指向您对策略 json 的引用的链接。将发布答案。
标签: amazon-web-services terraform amazon-iam