generated from appvia/terraform-aws-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata.tf
87 lines (71 loc) · 1.99 KB
/
data.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
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
85
86
87
## Find the current AWS account ID
data "aws_caller_identity" "current" {}
## Find the current AWS region
data "aws_region" "current" {}
## Find the aws partition
data "aws_partition" "current" {}
## Provision an SNS IAM policy allowing the account root
data "aws_iam_policy_document" "current" {
statement {
sid = "AllowAccountRoot"
effect = "Allow"
principals {
type = "AWS"
identifiers = [format("arn:aws:iam::%s:root", local.account_id)]
}
actions = [
"sns:Publish"
]
resources = ["*"]
}
dynamic "statement" {
for_each = var.allowed_aws_services
content {
sid = "AllowService${index(var.allowed_aws_services, statement.value)}"
effect = "Allow"
principals {
type = "Service"
identifiers = [statement.value]
}
actions = [
"sns:Publish"
]
resources = ["*"]
}
}
dynamic "statement" {
for_each = var.allowed_aws_principals
content {
sid = "AllowPrincipal${index(var.allowed_aws_principals, statement.value)}"
effect = "Allow"
principals {
type = "AWS"
identifiers = [statement.value]
}
actions = [
"sns:Publish"
]
resources = ["*"]
}
}
}
## Find the slack secret if required
data "aws_secretsmanager_secret" "slack" {
count = local.enable_slack_secret ? 1 : 0
name = var.slack.secret_name
}
## Find the latest version of the slack secret if required
data "aws_secretsmanager_secret_version" "slack" {
count = local.enable_slack_secret ? 1 : 0
secret_id = data.aws_secretsmanager_secret.slack[0].id
}
## Find the teams secret if required
data "aws_secretsmanager_secret" "teams" {
count = local.enable_teams_secret ? 1 : 0
name = var.teams.secret_name
}
## Find the latest version of the teams secret if required
data "aws_secretsmanager_secret_version" "teams" {
count = local.enable_teams_secret ? 1 : 0
secret_id = data.aws_secretsmanager_secret.teams[0].id
}