Created
April 24, 2017 18:25
-
-
Save baskaran-md/08729036dbbcd14122e66674b2ec54c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_iam_role" "role" { | |
name = "test_role" | |
assume_role_policy = "${data.aws_iam_policy_document.ec2-principal.json}" | |
} | |
resource "aws_iam_instance_profile" "test_profile" { | |
name = "test_profile" | |
role = "${aws_iam_role.role.name}" | |
} |
Error while validating / terraform planning
[iam/terraform] (master) >>> terraform validate
Error loading files Error loading $DIR/iam/terraform/policies.tf.json: position -: 'data' must be followed by exactly two strings: a type and a name
However, Referring to hashicorp/terraform#13037, I modified the tf.json file as below.
{
"data": [{
"aws_iam_policy_document": [{
"ec2-principal":{
"statement": {
"action": [
"sts:AssumeRole"
],
"principals": {
"type": "Service",
"identifiers": [
"ec2.amazonaws.com"
]
},
"effect": "Allow"
}
},
"s3-read-only":{
"statement":{
"action":[
"s3:ListAllMyBuckets",
"s3:GetBucketLocation"
],
"resources":[
"arn:aws:s3:::*"
]
}
}
}]
}]
}
Now, on doing terraform validate
I am getting this error.
Error validating: 2 error(s) occurred:
* resource 'aws_iam_role.role' config: unknown resource 'data.aws_iam_policy_document.ec2-principal' referenced in variable data.aws_iam_policy_document.ec2-principal.json
* resource 'aws_iam_policy.policy' config: unknown resource 'data.aws_iam_policy_document.s3-read-only' referenced in variable data.aws_iam_policy_document.s3-read-only.json
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
policies.tf.json