Error: "policy" contains an invalid JSON policy

I need help to figure out what is wrong with my terraform


[root@delloel82 terraform]# terraform -v
Terraform v0.12.29

  • provider.aws v2.70.0
    [root@delloel82 terraform]#

[root@delloel82 terraform]# more ec2-assume-policy.json ec2-policy.json iam.tf ec2.tf s3.tf
::::::::::::::
ec2-assume-policy.json
::::::::::::::
{
“Version”: “2012-10-17”,
“Statement”: [
{
“Action”: “sts:AssumeRole”,
“Principal”: {
“Service”: “ec2.amazonaws.com
},
“Effect”: “Allow”,
“Sid”: “”
}
]
}
::::::::::::::
ec2-policy.json
::::::::::::::
{
“Version”: “2012-10-17”,
“Statement”: [
{
“Action”: [
“ec2:"
],
“Effect”: “Allow”,
“Resource”: "

}
]
}
::::::::::::::
iam.tf
::::::::::::::
resource “aws_iam_role_policy” “ec2_policy” {
name = “ec2_policy”
role = “aws_iam_role.javahome_ec2_role.id”

policy = “file(ec2-policy.json)”
}

resource “aws_iam_role” “javahome_ec2_role” {
name = “javahome_ec2_role”
assume_role_policy = “file(ec2-assume-policy.json)”
}

Let us create the instance profile to be attached to ec2 instance

resource “aws_iam_instance_profile” “ec2_profile” {
name = “javahome_ec2_profile”
role = “aws_iam_role.javahome_ec2_role.name”
}
::::::::::::::
ec2.tf
::::::::::::::
provider “aws” {
region = “us-east-1”
}

resource “aws_instance” “web” {
ami = “ami-08f3d892de259504d”
instance_type = “t2.micro”
iam_instance_profile = “aws_iam_instance_profile.ec2_profile.name”

tags = {
Name = “HelloWorld”
}
}
::::::::::::::
s3.tf
::::::::::::::

Note: I have use the follwing doc as reference

https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket

On this file we are to create the new

bucket mentioned in the iam.tf file

resource “aws_s3_bucket” “myfoxec2-bucket9594” {
bucket = “myfoxec2-bucket9594”
acl = “private”
}
[root@delloel82 terraform]#
[root@delloel82 terraform]#
[root@delloel82 terraform]# terraform init

Initializing the backend…

Initializing provider plugins…

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, it is recommended to add version = “…” constraints to the
corresponding provider blocks in configuration, with the constraint strings
suggested below.

  • provider.aws: version = “~> 2.70”

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running “terraform plan” to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.
[root@delloel82 terraform]#

Running terraform apply I am getting some error of which I can’t find a solution. Can someone help?

[root@delloel82 terraform]#
[root@delloel82 terraform]#
[root@delloel82 terraform]#
[root@delloel82 terraform]# terraform apply

Error: “policy” contains an invalid JSON policy

on iam.tf line 1, in resource “aws_iam_role_policy” “ec2_policy”:
1: resource “aws_iam_role_policy” “ec2_policy” {

Error: “assume_role_policy” contains an invalid JSON: invalid character ‘i’ in literal false (expecting ‘a’)

on iam.tf line 8, in resource “aws_iam_role” “javahome_ec2_role”:
8: resource “aws_iam_role” “javahome_ec2_role” {

[root@delloel82 terraform]#

Can someone help figure out what I am doing wrong here?

Regards
Mamadou Diatta