-
Notifications
You must be signed in to change notification settings - Fork 0
/
ec2_iam.tf
32 lines (32 loc) · 1.17 KB
/
ec2_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
28
29
30
31
32
resource "aws_iam_instance_profile" "bastion_iam_profile" {
name = "bastion_iam_profile"
role = aws_iam_role.bastion_iam_role.name
}
resource "aws_iam_role" "bastion_iam_role" {
name = "bastion_iam_role"
assume_role_policy = data.aws_iam_policy_document.bastion_iam_role_policy_document.json
}
data "aws_iam_policy_document" "bastion_iam_role_policy_document" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_policy_attachment" "ssm_core_policy_attach" {
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
roles = [aws_iam_role.bastion_iam_role.name]
name = "ssm_core_policy_attach"
}
resource "aws_iam_policy_attachment" "rds_policy_attach" {
policy_arn = "arn:aws:iam::aws:policy/AmazonRDSFullAccess"
roles = [aws_iam_role.bastion_iam_role.name]
name = "rds_policy_attach"
}
resource "aws_iam_policy_attachment" "ssm_patch_policy_attach" {
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMPatchAssociation"
roles = [aws_iam_role.bastion_iam_role.name]
name = "ssm_patch_policy_attach"
}