|
| 1 | +module "vpc" { |
| 2 | + source = "terraform-aws-modules/vpc/aws" |
| 3 | + |
| 4 | + name = "${terraform.workspace}-vpc" |
| 5 | + cidr = var.cidr |
| 6 | + |
| 7 | + azs = var.azs |
| 8 | + public_subnets = var.public_subnets |
| 9 | + |
| 10 | + enable_nat_gateway = false |
| 11 | +} |
| 12 | + |
| 13 | +module "lb" { |
| 14 | + source = "./modules/lb" |
| 15 | + vpc_id = module.vpc.vpc_id |
| 16 | + acm_certificate_arn = var.acm_certificate_arn |
| 17 | + health_check_path = "/" |
| 18 | + public_subnets = module.vpc.public_subnets |
| 19 | +} |
| 20 | + |
| 21 | +module "ecs" { |
| 22 | + source = "./modules/ecs" |
| 23 | + vpc_id = module.vpc.vpc_id |
| 24 | + public_subnets = module.vpc.public_subnets |
| 25 | + instance_type = var.instance_type |
| 26 | + alb_sg_id = module.lb.alb_sg_id |
| 27 | + region = var.region |
| 28 | +} |
| 29 | + |
| 30 | +module "route53" { |
| 31 | + source = "./modules/route53" |
| 32 | + zone_name = var.zone_name |
| 33 | + record_name = var.record_name |
| 34 | + alb_dns_name = module.lb.dns_name |
| 35 | +} |
| 36 | + |
| 37 | +module "redis" { |
| 38 | + source = "./modules/redis" |
| 39 | + name = "redis" |
| 40 | + vpc_id = module.vpc.vpc_id |
| 41 | + ecs_cluster_id = module.ecs.cluster_id |
| 42 | + public_subnets = module.vpc.public_subnets |
| 43 | + ecs_sg_id = module.ecs.ecs_sg_id |
| 44 | + image = "redis:latest" |
| 45 | + region = var.region |
| 46 | + service_discovery_arn = module.ecs.registry_arn |
| 47 | + ecs_service_iam_role_arn = module.ecs.service_iam_role_arn |
| 48 | +} |
| 49 | + |
| 50 | +# locals { |
| 51 | +# be_image = "${var.ecr_app_repo}:${var.app_image_tag}" |
| 52 | +# env_vars = [ |
| 53 | +# { |
| 54 | +# name = "REDIS_HOST" |
| 55 | +# value = "redis" |
| 56 | +# } |
| 57 | +# ] |
| 58 | +# } |
| 59 | + |
| 60 | +# module "app" { |
| 61 | +# source = "./modules/app" |
| 62 | +# name = "gunicorn" |
| 63 | +# ecs_cluster_id = module.ecs.cluster_id |
| 64 | +# task_role_arn = module.ecs.task_role_arn |
| 65 | +# ecs_service_iam_role_arn = module.ecs.service_iam_role_arn |
| 66 | +# command = ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:app"] |
| 67 | +# env_vars = local.env_vars |
| 68 | +# image = local.be_image |
| 69 | +# alb_default_tg_arn = module.lb.alb_default_tg_arn |
| 70 | +# log_group_name = "/ecs/${terraform.workspace}/app" |
| 71 | +# log_stream_prefix = "app" |
| 72 | +# region = var.region |
| 73 | +# cpu = var.app_cpu |
| 74 | +# memory = var.app_memory |
| 75 | +# port = 8000 |
| 76 | +# path_patterns = ["/*"] |
| 77 | +# health_check_path = "/api/status/" |
| 78 | +# listener_arn = module.lb.listener_arn |
| 79 | +# vpc_id = module.vpc.vpc_id |
| 80 | +# priority = 1 |
| 81 | +# } |
0 commit comments