-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
51 lines (43 loc) · 1.16 KB
/
main.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (C) 2020 DevOps, SIA. - All Rights Reserved
* You may use, distribute and modify this code under the
* terms of the Apache License Version 2.0.
* http://www.apache.org/licenses
*/
module "label" {
source = "git::https://github.com/cloudposse/terraform-null-label.git?ref=tags/0.16.0"
namespace = var.namespace
name = var.name
stage = var.stage
environment = var.environment
delimiter = var.delimiter
attributes = var.attributes
tags = var.tags
}
data "aws_iam_policy_document" "ssm" {
statement {
actions = [
"sts:AssumeRole",
]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
effect = "Allow"
}
}
resource "aws_iam_role" "this" {
name = module.label.id
assume_role_policy = data.aws_iam_policy_document.ssm.json
}
resource "aws_iam_role_policy_attachment" "this" {
role = aws_iam_role.this.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
lifecycle {
create_before_destroy = true
}
}
resource "aws_iam_instance_profile" "this" {
name = module.label.id
role = aws_iam_role.this.name
}