...
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_cloud_run_v2_service" "default" {
19 name = "cloudrun-service"
20 location = "us-central1"
21
22 template {
23 containers {
24 image = "us-docker.pkg.dev/cloudrun/container/hello"
25 }
26 vpc_access{
27 connector = google_vpc_access_connector.connector.id
28 egress = "ALL_TRAFFIC"
29 }
30 }
31}
32
33resource "google_vpc_access_connector" "connector" {
34 name = "run-vpc"
35 subnet {
36 name = google_compute_subnetwork.custom_test.name
37 }
38 machine_type = "e2-standard-4"
39 min_instances = 2
40 max_instances = 3
41 region = "us-central1"
42}
43resource "google_compute_subnetwork" "custom_test" {
44 name = "run-subnetwork"
45 ip_cidr_range = "10.2.0.0/28"
46 region = "us-central1"
47 network = google_compute_network.custom_test.id
48}
49resource "google_compute_network" "custom_test" {
50 name = "run-network"
51 auto_create_subnetworks = false
52}
53```
View as plain text