generated from dxw/terraform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathssm-dhmc.tf
30 lines (23 loc) · 971 Bytes
/
ssm-dhmc.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
resource "aws_iam_role" "ssm_dhmc" {
count = local.enable_ssm_dhmc ? 1 : 0
name = "${local.project_name}-ssm-dhmc"
assume_role_policy = templatefile(
"${path.root}/policies/assume-roles/service-principle-standard.json.tpl",
{ services = jsonencode(["ssm.amazonaws.com"]) }
)
}
resource "aws_iam_policy" "ssm_dhmc" {
count = local.enable_ssm_dhmc ? 1 : 0
name = "${local.project_name}-ssm-dhmc"
policy = templatefile("${path.root}/policies/ssm-dhmc.json.tpl", {})
}
resource "aws_iam_role_policy_attachment" "ssm_dhmc" {
count = local.enable_ssm_dhmc ? 1 : 0
role = aws_iam_role.ssm_dhmc[0].name
policy_arn = aws_iam_policy.ssm_dhmc[0].arn
}
resource "aws_ssm_service_setting" "ssm_dhmc" {
count = local.enable_ssm_dhmc ? 1 : 0
setting_id = "arn:aws:ssm:${local.aws_region}:${local.aws_account_id}:servicesetting/ssm/managed-instance/default-ec2-instance-management-role"
setting_value = aws_iam_role.ssm_dhmc[0].name
}