resource "aws_iam_role" "ec2_iam_role" {
name = "EC2-IAM-Role"
assume_role_policy = <<EOF
{
"Version": "2023-01-09",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": ["ec2.amazonaws.com",application-autoscaling.amazonaws.com"]
},
"Action": "sts:AssumeRole"
}
]
}
EOF
}
I am getting the following error :
Error: "assume_role_policy" contains an invalid JSON: invalid character 'a' looking for beginning of value
│
│ with aws_iam_role.ec2_iam_role,
│ on instances.tf line 97, in resource "aws_iam_role" "ec2_iam_role":
│ 97: assume_role_policy = <<EOF
│ 98: {
│ 99: "Version": "2023-01-09",
│ 100: "Statement": [
│ 101: {
│ 102: "Effect": "Allow",
│ 103: "Principal": {
│ 104: "Service": ["ec2.amazonaws.com",application-autoscaling.amazonaws.com"]
│ 105: },
│ 106: "Action": "sts:AssumeRole"
│ 107: }
│ 108: ]
│ 109: }
│ 110: EOF
Can anyone please help ?