-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
116 lines (96 loc) · 2.81 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
111
112
113
114
115
116
provider "aws" {
access_key = var.aws-access-key
secret_key = var.aws-secret-key
region = var.aws-region
}
resource "aws_s3_bucket" "terraform_state" {
bucket = var.terraform_state
lifecycle {
prevent_destroy = true
}
versioning {
enabled = true
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_dynamodb_table" "dynamodb-terraform-state-lock" {
name = "terraform-state-locking"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
# read_capacity = 20
# write_capacity = 20
attribute {
name = "LockID"
type = "S"
}
tags = {
Name = var.project_tag
}
}
terraform {
backend "s3" {
bucket = "project-terraform-backend-store-varnish"
key = "global/s3/terraform.tfstate"
region = "us-east-1"
dynamodb_table = "dynamodb-terraform-state-lock"
encrypt = true
}
}
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
container_image = "${module.ecr.aws_ecr_repository_url}/${var.container_image}:latest"
mycontainer = "${module.ecr.aws_ecr_repository_url}:latest"
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 }
]
}