This repository has been archived by the owner on Apr 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
100 lines (82 loc) · 1.97 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
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
88
89
90
91
92
93
94
95
96
97
98
99
terraform {
required_version = ">= 0.12"
}
resource "aws_ebs_encryption_by_default" "on" {
enabled = true
}
module "vpc" {
source = "./vpc"
env = var.env
cidr = var.cidr_block
}
#####
# Create base resources that the other modules will look up
#####
module "encryptkey" {
source = "./encryptkey"
env = var.env
}
module "wildcard" {
source = "./wildcard_cert"
env = var.env
domain_name = var.domain_name
primary = var.primary
}
module "ingress" {
source = "./ingress"
env = var.env
domain_name = var.domain_name
public = var.public_ingress
cidr_block = var.cidr_block
vpc_id = module.vpc.id
subnet_ids = {
application = module.vpc.application[*].id
public = module.vpc.public[*].id
}
internal_dns = module.vpc.internal_dns
external_dns = data.aws_route53_zone.external
wildcard_arn = module.wildcard.arn
}
#####
# Singleton resources referenced by child modules
####
resource "aws_s3_bucket" "lambda_releases" {
bucket = "${var.domain_name}-${var.env}-lambda-releases"
acl = "private"
versioning {
enabled = true
}
tags = {
env = var.env
terraform = "true"
app = "lambda-releases"
}
}
### Shared IAM role for instances running teleport
resource "aws_iam_policy" "teleport_secrets" {
name = "${var.env}-instance-teleport-secrets"
path = "/${var.env}/teleport/"
description = "Allows nodes to run local teleport daemon"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect" : "Allow",
"Action" : "ec2:DescribeTags",
"Resource" : "*"
},
{
"Effect": "Allow",
"Action": "secretsmanager:GetSecretValue",
"Resource": "${data.aws_secretsmanager_secret.cluster_token.arn}"
},
{
"Effect": "Allow",
"Action": "kms:Decrypt",
"Resource": "${module.encryptkey.arn}"
}
]
}
EOF
}