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