Skip to content

Commit 3e3c045

Browse files
authored
Fix examples (#33)
1 parent 6fffbf9 commit 3e3c045

File tree

1 file changed

+50
-12
lines changed

1 file changed

+50
-12
lines changed

examples/test/main.tf

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,77 @@
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+
16
module "cluster" {
27
source = "cn-terraform/ecs-cluster/aws"
3-
name = "test-cluster"
8+
name = "test"
49
}
510

611
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+
}
1351
}
1452

1553
module "td" {
1654
source = "cn-terraform/ecs-fargate-task-definition/aws"
17-
name_prefix = "test-td"
55+
name_prefix = "test"
1856
container_image = "ubuntu"
1957
container_name = "test"
2058
}
2159

2260
module "service" {
2361
source = "cn-terraform/ecs-fargate-service/aws"
24-
name_prefix = "test-service"
62+
name_prefix = "test"
2563
vpc_id = module.base-network.vpc_id
2664
ecs_cluster_arn = module.cluster.aws_ecs_cluster_cluster_arn
2765
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
3068
container_name = "test"
3169
enable_autoscaling = false
3270
}
3371

3472
module "ecs-service-autoscaling" {
3573
source = "../../"
36-
name_prefix = "test-as"
74+
name_prefix = "test"
3775
ecs_cluster_name = module.cluster.aws_ecs_cluster_cluster_name
3876
ecs_service_name = module.service.aws_ecs_service_service_name
3977
# region = "us-east-1"

0 commit comments

Comments
 (0)