/
main.tf
69 lines (65 loc) · 2.25 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
# [START vpc_serverless_connector_enable_api]
resource "google_project_service" "vpcaccess-api" {
project = var.project_id # Replace this with your project ID in quotes
service = "vpcaccess.googleapis.com"
}
# [END vpc_serverless_connector_enable_api]
# [START vpc_serverless_connector]
module "test-vpc-module" {
source = "terraform-google-modules/network/google"
version = "~> 9.0"
project_id = var.project_id # Replace this with your project ID in quotes
network_name = "my-serverless-network"
mtu = 1460
subnets = [
{
subnet_name = "serverless-subnet"
subnet_ip = "10.10.10.0/28"
subnet_region = "us-central1"
}
]
}
module "serverless-connector" {
source = "terraform-google-modules/network/google//modules/vpc-serverless-connector-beta"
version = "~> 9.0"
project_id = var.project_id
vpc_connectors = [{
name = "central-serverless"
region = "us-central1"
subnet_name = module.test-vpc-module.subnets["us-central1/serverless-subnet"].name
# host_project_id = var.host_project_id # Specify a host_project_id for shared VPC
machine_type = "e2-standard-4"
min_instances = 2
max_instances = 7
}
# Uncomment to specify an ip_cidr_range
# , {
# name = "central-serverless2"
# region = "us-central1"
# network = module.test-vpc-module.network_name
# ip_cidr_range = "10.10.11.0/28"
# subnet_name = null
# machine_type = "e2-standard-4"
# min_instances = 2
# max_instances = 7 }
]
depends_on = [
google_project_service.vpcaccess-api
]
}
# [END vpc_serverless_connector]