aws_iam_role.s3_access_role: Error creating IAM Role s3_access_r

Hello ,

I see below error while applying. not sure if the problem is with the code ?

following is the code


resource "aws_iam_role_policy" "s3_access_policy" {
name = "s3_access_policy"
role = "${aws_iam_role.s3_access_role.id}"

policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
EOF
}

resource "aws_iam_role" "s3_access_role" {
name = "s3_access_role"

assume_role_policy = <<EOF
{
"version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}

and the error is 



Error: Error applying plan:

1 error(s) occurred:

* aws_iam_role.s3_access_role: 1 error(s) occurred:

* aws_iam_role.s3_access_role: Error creating IAM Role s3_access_role: MalformedPolicyDocument: Unknown field version
status code: 400, request id: c1d097e2-046d-11e9-9a74-8d9c0ba14f29

any idea how to fix this? tried to search for a solution in google, get much help.

  • post-author-pic
    Praveen Kumar N
    12-20-2018

    Please ignore this post, i found the issue, "version" V was lower case. , it supposed to be Upper case


Looking For Team Training?

Learn More