-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
110 lines (99 loc) · 3.14 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
100
101
102
103
104
105
106
107
108
109
110
provider "aws" {
region = "us-east-1"
}
terraform {
required_version = ">= 0.14"
backend "s3" {
bucket = "dk-terraform-backend-store"
encrypt = true
key = "terraform.tfstate"
region = "us-east-1"
dynamodb_table = "terraform-state-lock-dynamo"
}
}
resource "aws_dynamodb_table" "dynamodb-terraform-state-lock" {
name = "terraform-state-lock-dynamo"
hash_key = "LockID"
read_capacity = 20
write_capacity = 20
attribute {
name = "LockID"
type = "S"
}
tags = {
Name = "DynamoDB Terraform State Lock Table"
}
}
module "vpc" {
source = "./modules/vpc"
cidr = var.cidr
private_subnets = var.private_subnets
public_subnets = var.public_subnets
availability_zones = var.availability_zones
}
module "security_groups" {
source = "./modules/security-groups"
name = var.name
vpc_id = module.vpc.id
environment = var.environment
container_port = var.container_port
}
module "primary_domain" {
source = "./modules/route53-public"
primary_domain_name = var.domain_name
primary_domain_name_comment = var.comment_domain_name
}
module "generate_certificate" {
source = "./modules/acm"
domain_name = var.domain_name_cert
domain_zone_id = module.primary_domain.primary_domain_hosted_zone_id
}
module "alb" {
source = "./modules/alb"
name = var.name
vpc_id = module.vpc.id
subnets = module.vpc.public_subnets
environment = var.environment
alb_security_groups = [module.security_groups.alb]
alb_tls_cert_arn = var.arn_certificate
health_check_path = var.health_check_path
domain_name = var.domain_name
subdomain_name = "app.${var.domain_name}"
zone_id = module.primary_domain.primary_domain_hosted_zone_id
}
module "ecr" {
source = "./modules/ecr"
name = var.name
environment = var.environment
}
module "secrets" {
source = "./modules/secrets"
name = var.name
environment = var.environment
application-secrets = var.application-secrets
}
module "ecs" {
source = "./modules/ecs"
name = var.name
environment = var.environment
region = var.aws-region
subnets = module.vpc.private_subnets
aws_alb_target_group_arn = module.alb.aws_alb_target_group_arn
ecs_service_security_groups = [module.security_groups.ecs_tasks]
container_port = var.container_port
container_cpu = var.container_cpu
container_memory = var.container_memory
service_desired_count = var.service_desired_count
container_environment = [
{ name = "LOG_LEVEL",
value = "DEBUG" },
{ name = "PORT",
value = var.container_port }
]
container_secrets = module.secrets.secrets_map
container_image = module.ecr.aws_ecr_repository_url
container_secrets_arns = module.secrets.application_secrets_arn
}
module "database" {
source = "./modules/db"
}