Skip to content

Commit bf6f70c

Browse files
authored
Update networking module in example (#97)
1 parent 654adf1 commit bf6f70c

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed

examples/test/main.tf

+43-9
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,55 @@
11
module "base-network" {
2-
source = "cn-terraform/networking/aws"
3-
version = "2.0.16"
2+
source = "cn-terraform/networking/aws"
3+
version = "3.0.0"
44

5-
name_prefix = "test-networking"
6-
vpc_cidr_block = "192.168.0.0/16"
7-
availability_zones = ["us-east-1a", "us-east-1b", "us-east-1c", "us-east-1d"]
8-
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"]
9-
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"]
5+
cidr_block = "192.168.0.0/16"
6+
7+
public_subnets = {
8+
first_public_subnet = {
9+
availability_zone = "us-east-1a"
10+
cidr_block = "192.168.0.0/19"
11+
}
12+
second_public_subnet = {
13+
availability_zone = "us-east-1b"
14+
cidr_block = "192.168.32.0/19"
15+
}
16+
third_public_subnet = {
17+
availability_zone = "us-east-1c"
18+
cidr_block = "192.168.64.0/19"
19+
}
20+
fourth_public_subnet = {
21+
availability_zone = "us-east-1d"
22+
cidr_block = "192.168.96.0/19"
23+
}
24+
}
25+
26+
private_subnets = {
27+
first_private_subnet = {
28+
availability_zone = "us-east-1a"
29+
cidr_block = "192.168.128.0/19"
30+
}
31+
second_private_subnet = {
32+
availability_zone = "us-east-1b"
33+
cidr_block = "192.168.160.0/19"
34+
}
35+
third_private_subnet = {
36+
availability_zone = "us-east-1c"
37+
cidr_block = "192.168.192.0/19"
38+
}
39+
fourth_private_subnet = {
40+
availability_zone = "us-east-1d"
41+
cidr_block = "192.168.224.0/19"
42+
}
43+
}
1044
}
1145

1246
module "sonar" {
1347
source = "../../"
1448
name_prefix = "sonar"
1549
region = "us-east-1"
1650
vpc_id = module.base-network.vpc_id
17-
public_subnets_ids = module.base-network.public_subnets_ids
18-
private_subnets_ids = module.base-network.private_subnets_ids
51+
public_subnets_ids = [for subnet in module.base-network.public_subnets : subnet.id]
52+
private_subnets_ids = [for subnet in module.base-network.private_subnets : subnet.id]
1953
db_instance_size = "db.t3.medium"
2054
enable_ssl = false
2155
lb_https_ports = {}

main.tf

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ locals {
88
sonar_db_name = var.db_name
99
sonar_db_username = var.db_username
1010
sonar_db_password = var.db_password == "" ? random_password.master_password.result : var.db_password
11-
12-
default_certificate_arn = var.default_certificate_arn == "" || var.enable_ssl == true ? module.acm[0].acm_certificate_arn : var.default_certificate_arn
11+
default_certificate_arn = (
12+
var.default_certificate_arn == "" && var.enable_ssl
13+
) ? try(module.acm[0].acm_certificate_arn, null) : var.default_certificate_arn
1314
}
1415

1516
#------------------------------------------------------------------------------

0 commit comments

Comments
 (0)