Created
September 4, 2024 15:47
-
-
Save msfidelis/dde603130e8bd11b305fe51cc71e47ce 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" "main" { | |
name = format("%s-instance-profile", var.project_name) | |
assume_role_policy = jsonencode({ | |
Version = "2012-10-17" | |
Statement = [{ | |
Action = "sts:AssumeRole" | |
Effect = "Allow" | |
Principal = { | |
Service = "ec2.amazonaws.com" | |
} | |
}] | |
}) | |
} | |
resource "aws_iam_role_policy_attachment" "ec2_role" { | |
role = aws_iam_role.main.name | |
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEC2ContainerServiceforEC2Role" | |
} | |
resource "aws_iam_role_policy_attachment" "ec2_ssm" { | |
role = aws_iam_role.main.name | |
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM" | |
} | |
resource "aws_iam_instance_profile" "main" { | |
name = format("%s-instance-profile", var.project_name) | |
role = aws_iam_role.main.name | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment