-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathmain.tf
91 lines (84 loc) · 2.61 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
provider "aws" {
access_key = var.aws-access-key
secret_key = var.aws-secret-key
region = var.aws-region
version = "~> 2.0"
}
terraform {
backend "s3" {
bucket = "terraform-backend-store"
encrypt = true
key = "terraform.tfstate"
region = "eu-central-1"
# dynamodb_table = "terraform-state-lock-dynamo" - uncomment this line once the terraform-state-lock-dynamo has been terraformed
}
}
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 = "./vpc"
name = var.name
cidr = var.cidr
private_subnets = var.private_subnets
public_subnets = var.public_subnets
availability_zones = var.availability_zones
environment = var.environment
}
module "security_groups" {
source = "./security-groups"
name = var.name
vpc_id = module.vpc.id
environment = var.environment
container_port = var.container_port
}
module "alb" {
source = "./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.tsl_certificate_arn
health_check_path = var.health_check_path
}
module "ecr" {
source = "./ecr"
name = var.name
environment = var.environment
}
module "ecs" {
source = "./ecs"
name = var.name
environment = var.environment
region = var.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
container_image = module.ecr.aws_ecr_repository_url
service_desired_count = var.service_desired_count
container_environment = [
{ name = "LOG_LEVEL",
value = "DEBUG" },
{ name = "PORT",
value = var.container_port }
]
container_secrets = [
{ name = "API_KEYS",
valueFrom = aws_secretsmanager_secret_version.api_keys_value.arn }
]
secret_arn = aws_secretsmanager_secret_version.api_keys_value.arn
}