-
Notifications
You must be signed in to change notification settings - Fork 0
/
iam.tf
27 lines (25 loc) · 799 Bytes
/
iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Iam ec2 instance profile to allow SSM access to ec2 instances
data "aws_iam_policy_document" "ec2_assume_role_for_ssm" {
version = "2012-10-17"
statement {
sid = "Ec2AssumeRoleForSSM"
effect = "Allow"
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
actions = [
"sts:AssumeRole",
]
}
}
resource "aws_iam_role" "ec2_role_for_ssm" {
name = "ec2-role-for-ssm"
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role_for_ssm.json
managed_policy_arns = ["arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"]
tags = var.common_tags
}
resource "aws_iam_instance_profile" "ec2_role_for_ssm" {
name = "ec2-ssm-instance-profile"
role = aws_iam_role.ec2_role_for_ssm.name
}