Created
October 19, 2020 21:24
-
-
Save bmwitcher/5e6d1b4a0b7a629f311a6d90e227676c to your computer and use it in GitHub Desktop.
creating iam roles, polcies, and attachemts for vpc endpoint lab
This file contains hidden or 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" "ec2_s3_access_role" { | |
name = "ec2-s3" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "ec2.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
"Sid": "" | |
} | |
] | |
} | |
EOF | |
} | |
resource "aws_iam_instance_profile" "ec2profile" { | |
name = "ec2profile" | |
role = aws_iam_role.ec2_s3_access_role.name | |
} | |
resource "aws_iam_policy" "policy" { | |
name = "ec2_S3policy" | |
description = "Access to s3 policy from ec2" | |
policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "s3:*", | |
"Resource": "*" | |
} | |
] | |
} | |
EOF | |
} | |
resource "aws_iam_role_policy_attachment" "ec2-attach" { | |
role = aws_iam_role.ec2_s3_access_role.name | |
policy_arn = aws_iam_policy.policy.arn | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment