-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathmain.tf
More file actions
84 lines (70 loc) · 1.93 KB
/
main.tf
File metadata and controls
84 lines (70 loc) · 1.93 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
provider "aws" {
region = "us-east-1"
}
# (Optional) backend configuration to manage terraform state file via S3.
#terraform {
# backend "s3" {
# bucket = "terraform-state-bucket"
# key = "environment/trend-micro-deep-security/terraform.tfstate"
# region = "us-east-1"
# encrypt = "true"
# }
#}
data "aws_iam_policy_document" "tmds_assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "AWS"
identifiers = ["arn:aws:iam::${var.tmds_aws_account_id}:root"]
}
condition {
test = "StringEquals"
variable = "sts:ExternalId"
values = [var.external_id]
}
}
}
data "aws_iam_policy_document" "tmds_role_policy_document" {
statement {
actions = [
"ec2:DescribeRegions",
"ec2:DescribeImages",
"ec2:DescribeInstances",
"ec2:DescribeTags",
"ec2:DescribeAvailabilityZones",
"ec2:DescribeSecurityGroups",
"ec2:DescribeSubnets",
"ec2:DescribeVpcs",
"iam:ListAccountAlias"
]
resources = ["*"]
}
statement {
actions = [
"iam:GetRole",
"iam:GetRolePolicy"
]
resources = [aws_iam_role.tmds_role.arn]
}
statement {
actions = [
"workspaces:DescribeWorkspaces",
"workspaces:DescribeWorkspaceDirectories",
"workspaces:DescribeWorkspaceBundles",
"workspaces:DescribeTags"
]
resources = ["*"]
}
}
resource "aws_iam_policy" "tmds_role_policy" {
name = "${var.environment}-${var.service_name}-role-policy"
policy = data.aws_iam_policy_document.tmds_role_policy_document.json
}
resource "aws_iam_role_policy_attachment" "tmds_role_policy_attachment" {
role = aws_iam_role.tmds_role.id
policy_arn = aws_iam_policy.tmds_role_policy.arn
}
resource "aws_iam_role" "tmds_role" {
name = "${var.environment}-${var.service_name}"
assume_role_policy = data.aws_iam_policy_document.tmds_assume_role_policy.json
}