|
| 1 | +locals { |
| 2 | + public_subnet_ids = [for s in module.base-network.public_subnets : s.id] |
| 3 | + private_subnet_ids = [for s in module.base-network.private_subnets : s.id] |
| 4 | +} |
| 5 | + |
1 | 6 | module "cluster" {
|
2 | 7 | source = "cn-terraform/ecs-cluster/aws"
|
3 |
| - name = "test-cluster" |
| 8 | + name = "test" |
4 | 9 | }
|
5 | 10 |
|
6 | 11 | module "base-network" {
|
7 |
| - source = "cn-terraform/networking/aws" |
8 |
| - name_prefix = "test-networking" |
9 |
| - vpc_cidr_block = "192.168.0.0/16" |
10 |
| - availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d"] |
11 |
| - public_subnets_cidrs_per_availability_zone = ["192.168.0.0/19", "192.168.32.0/19", "192.168.64.0/19", "192.168.96.0/19"] |
12 |
| - private_subnets_cidrs_per_availability_zone = ["192.168.128.0/19", "192.168.160.0/19", "192.168.192.0/19", "192.168.224.0/19"] |
| 12 | + source = "cn-terraform/networking/aws" |
| 13 | + cidr_block = "192.168.0.0/16" |
| 14 | + |
| 15 | + vpc_additional_tags = { |
| 16 | + vpc_tag1 = "tag1", |
| 17 | + vpc_tag2 = "tag2", |
| 18 | + } |
| 19 | + |
| 20 | + public_subnets = { |
| 21 | + first_public_subnet = { |
| 22 | + availability_zone = "us-east-1a" |
| 23 | + cidr_block = "192.168.0.0/19" |
| 24 | + } |
| 25 | + second_public_subnet = { |
| 26 | + availability_zone = "us-east-1b" |
| 27 | + cidr_block = "192.168.32.0/19" |
| 28 | + } |
| 29 | + } |
| 30 | + |
| 31 | + public_subnets_additional_tags = { |
| 32 | + public_subnet_tag1 = "tag1", |
| 33 | + public_subnet_tag2 = "tag2", |
| 34 | + } |
| 35 | + |
| 36 | + private_subnets = { |
| 37 | + first_private_subnet = { |
| 38 | + availability_zone = "us-east-1a" |
| 39 | + cidr_block = "192.168.128.0/19" |
| 40 | + } |
| 41 | + second_private_subnet = { |
| 42 | + availability_zone = "us-east-1b" |
| 43 | + cidr_block = "192.168.160.0/19" |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + private_subnets_additional_tags = { |
| 48 | + private_subnet_tag1 = "tag1", |
| 49 | + private_subnet_tag2 = "tag2", |
| 50 | + } |
13 | 51 | }
|
14 | 52 |
|
15 | 53 | module "td" {
|
16 | 54 | source = "cn-terraform/ecs-fargate-task-definition/aws"
|
17 |
| - name_prefix = "test-td" |
| 55 | + name_prefix = "test" |
18 | 56 | container_image = "ubuntu"
|
19 | 57 | container_name = "test"
|
20 | 58 | }
|
21 | 59 |
|
22 | 60 | module "service" {
|
23 | 61 | source = "cn-terraform/ecs-fargate-service/aws"
|
24 |
| - name_prefix = "test-service" |
| 62 | + name_prefix = "test" |
25 | 63 | vpc_id = module.base-network.vpc_id
|
26 | 64 | ecs_cluster_arn = module.cluster.aws_ecs_cluster_cluster_arn
|
27 | 65 | task_definition_arn = module.td.aws_ecs_task_definition_td_arn
|
28 |
| - public_subnets = module.base-network.public_subnets_ids |
29 |
| - private_subnets = module.base-network.private_subnets_ids |
| 66 | + public_subnets = local.public_subnet_ids |
| 67 | + private_subnets = local.private_subnet_ids |
30 | 68 | container_name = "test"
|
31 | 69 | enable_autoscaling = false
|
32 | 70 | }
|
33 | 71 |
|
34 | 72 | module "ecs-service-autoscaling" {
|
35 | 73 | source = "../../"
|
36 |
| - name_prefix = "test-as" |
| 74 | + name_prefix = "test" |
37 | 75 | ecs_cluster_name = module.cluster.aws_ecs_cluster_cluster_name
|
38 | 76 | ecs_service_name = module.service.aws_ecs_service_service_name
|
39 | 77 | # region = "us-east-1"
|
|
0 commit comments