Skip to content

Commit 732b54a

Browse files
authored
Merge pull request #23 from terraform-google-modules/adrienthebo/add-secondary-ranges-example
Add example with single VPC and more complex secondary networks
2 parents 7663f6a + c4c4eef commit 732b54a

File tree

4 files changed

+170
-0
lines changed

4 files changed

+170
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Secondary Ranges
2+
3+
This example configures a single simple VPC inside of a project.
4+
5+
This VPC has three subnets, with the first subnet being given two secondary
6+
ranges and the third being given a single secondary range.
7+
8+
[^]: (autogen_docs_start)
9+
10+
## Inputs
11+
12+
| Name | Description | Type | Default | Required |
13+
|------|-------------|:----:|:-----:|:-----:|
14+
| project\_id | The project ID to host the network in | string | - | yes |
15+
16+
## Outputs
17+
18+
| Name | Description |
19+
|------|-------------|
20+
| network\_name | The name of the VPC being created |
21+
| network\_self\_link | The URI of the VPC being created |
22+
| routes | The routes associated with this VPC |
23+
| subnets\_flow\_logs | Whether the subnets will have VPC flow logs enabled |
24+
| subnets\_ips | The IP and cidrs of the subnets being created |
25+
| subnets\_names | The names of the subnets being created |
26+
| subnets\_private\_access | Whether the subnets will have access to Google API's without a public IP |
27+
| subnets\_regions | The region where subnets will be created |
28+
| subnets\_secondary\_ranges | The secondary ranges associated with these subnets |
29+
30+
[^]: (autogen_docs_end)

examples/secondary_ranges/main.tf

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module "vpc-secondary-ranges" {
18+
source = "../../"
19+
project_id = "${var.project_id}"
20+
network_name = "vpc-secondary-ranges"
21+
22+
subnets = [
23+
{
24+
subnet_name = "secondary-ranges-subnet-01"
25+
subnet_ip = "10.10.10.0/24"
26+
subnet_region = "us-west1"
27+
},
28+
{
29+
subnet_name = "secondary-ranges-subnet-02"
30+
subnet_ip = "10.10.20.0/24"
31+
subnet_region = "us-west1"
32+
subnet_private_access = "true"
33+
subnet_flow_logs = "true"
34+
},
35+
{
36+
subnet_name = "secondary-ranges-subnet-03"
37+
subnet_ip = "10.10.30.0/24"
38+
subnet_region = "us-west1"
39+
},
40+
]
41+
42+
secondary_ranges = {
43+
secondary-ranges-subnet-01 = [
44+
{
45+
range_name = "subnet-01-01"
46+
ip_cidr_range = "192.168.64.0/24"
47+
},
48+
{
49+
range_name = "subnet-01-02"
50+
ip_cidr_range = "192.168.65.0/24"
51+
},
52+
]
53+
secondary-ranges-subnet-02 = []
54+
secondary-ranges-subnet-03 = [
55+
{
56+
range_name = "subnet-03-01"
57+
ip_cidr_range = "192.168.66.0/24"
58+
},
59+
]
60+
}
61+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
output "network_name" {
18+
value = "${module.vpc-secondary-ranges.network_name}"
19+
description = "The name of the VPC being created"
20+
}
21+
22+
output "network_self_link" {
23+
value = "${module.vpc-secondary-ranges.network_self_link}"
24+
description = "The URI of the VPC being created"
25+
}
26+
27+
output "subnets_names" {
28+
value = "${module.vpc-secondary-ranges.subnets_names}"
29+
description = "The names of the subnets being created"
30+
}
31+
32+
output "subnets_ips" {
33+
value = "${module.vpc-secondary-ranges.subnets_ips}"
34+
description = "The IP and cidrs of the subnets being created"
35+
}
36+
37+
output "subnets_regions" {
38+
value = "${module.vpc-secondary-ranges.subnets_regions}"
39+
description = "The region where subnets will be created"
40+
}
41+
42+
output "subnets_private_access" {
43+
value = "${module.vpc-secondary-ranges.subnets_private_access}"
44+
description = "Whether the subnets will have access to Google API's without a public IP"
45+
}
46+
47+
output "subnets_flow_logs" {
48+
value = "${module.vpc-secondary-ranges.subnets_flow_logs}"
49+
description = "Whether the subnets will have VPC flow logs enabled"
50+
}
51+
52+
output "subnets_secondary_ranges" {
53+
value = "${flatten(module.vpc-secondary-ranges.subnets_secondary_ranges)}"
54+
description = "The secondary ranges associated with these subnets"
55+
}
56+
57+
output "routes" {
58+
value = "${module.vpc-secondary-ranges.routes}"
59+
description = "The routes associated with this VPC"
60+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
variable "project_id" {
18+
description = "The project ID to host the network in"
19+
}

0 commit comments

Comments
 (0)