...
1/**
2 * Copyright 2022 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```hcl
18resource "google_compute_network" "net" {
19 name = "my-network"
20}
21
22resource "google_compute_subnetwork" "subnet" {
23 name = "my-subnetwork"
24 network = google_compute_network.net.id
25 ip_cidr_range = "10.0.0.0/16"
26 region = "us-central1"
27}
28
29resource "google_compute_router" "router" {
30 name = "my-router"
31 region = google_compute_subnetwork.subnet.region
32 network = google_compute_network.net.id
33
34 bgp {
35 asn = 64514
36 }
37}
38
39resource "google_compute_router_nat" "nat" {
40 name = "my-router-nat"
41 router = google_compute_router.router.name
42 region = google_compute_router.router.region
43 nat_ip_allocate_option = "AUTO_ONLY"
44 source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
45
46 log_config {
47 enable = true
48 filter = "ERRORS_ONLY"
49 }
50}
51```
View as plain text