Skip to content

Commit 0411dbb

Browse files
committed
ip_ranges var
1 parent b11ae47 commit 0411dbb

File tree

3 files changed

+30
-33
lines changed

3 files changed

+30
-33
lines changed

blueprints/third-party-solutions/wordpress/cloudrun/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,24 +107,25 @@ The above command will delete the associated resources so there will be no billa
107107

108108
| name | description | type | required | default |
109109
|---|---|:---:|:---:|:---:|
110-
| [project_id](variables.tf#L51) | Project id, references existing project if `project_create` is null. | <code>string</code> || |
111-
| [wordpress_image](variables.tf#L75) | Image to run with Cloud Run, starts with \"gcr.io\" | <code>string</code> || |
110+
| [project_id](variables.tf#L66) | Project id, references existing project if `project_create` is null. | <code>string</code> || |
111+
| [wordpress_image](variables.tf#L77) | Image to run with Cloud Run, starts with \"gcr.io\" | <code>string</code> || |
112112
| [cloud_run_invoker](variables.tf#L18) | IAM member authorized to access the end-point (for example, 'user:YOUR_IAM_USER' for only you or 'allUsers' for everyone) | <code>string</code> | | <code>&#34;allUsers&#34;</code> |
113-
| [connector_cidr](variables.tf#L24) | CIDR block for the VPC serverless connector (10.8.0.0/28 by default) | <code>string</code> | | <code>&#34;10.8.0.0&#47;28&#34;</code> |
114-
| [prefix](variables.tf#L30) | Unique prefix used for resource names. Not used for project if 'project_create' is null. | <code>string</code> | | <code>&#34;&#34;</code> |
115-
| [principals](variables.tf#L36) | List of emails of people/service accounts to give rights to, eg 'user@domain.com'. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
116-
| [project_create](variables.tf#L42) | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
117-
| [psa_cidr](variables.tf#L57) | CIDR block for Private Service Access for CloudSQL (10.60.0.0/24 by default) | <code>string</code> | | <code>&#34;10.60.0.0&#47;24&#34;</code> |
118-
| [region](variables.tf#L63) | Region for the created resources | <code>string</code> | | <code>&#34;europe-west4&#34;</code> |
119-
| [sql_vpc_cidr](variables.tf#L69) | CIDR block for the VPC for the CloudSQL (10.0.0.0/20 by default) | <code>string</code> | | <code>&#34;10.0.0.0&#47;20&#34;</code> |
120-
| [wordpress_port](variables.tf#L80) | Port for the Wordpress image (8080 by default) | <code>number</code> | | <code>8080</code> |
113+
| [cloudsql_password](variables.tf#L24) | CloudSQL password (will be randomly generated by default) | <code>string</code> | | <code>null</code> |
114+
| [ip_ranges](variables.tf#L31) | CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC | <code title="object&#40;&#123;&#10; connector &#61; string&#10; psa &#61; string&#10; sql_vpc &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code title="&#123;&#10; connector &#61; &#34;10.8.0.0&#47;28&#34;&#10; psa &#61; &#34;10.60.0.0&#47;24&#34;&#10; sql_vpc &#61; &#34;10.0.0.0&#47;20&#34;&#10;&#125;">&#123;&#8230;&#125;</code> |
115+
| [prefix](variables.tf#L45) | Unique prefix used for resource names. Not used for project if 'project_create' is null. | <code>string</code> | | <code>&#34;&#34;</code> |
116+
| [principals](variables.tf#L51) | List of emails of people/service accounts to give rights to, eg 'user@domain.com'. | <code>list&#40;string&#41;</code> | | <code>&#91;&#93;</code> |
117+
| [project_create](variables.tf#L57) | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object&#40;&#123;&#10; billing_account_id &#61; string&#10; parent &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |
118+
| [region](variables.tf#L71) | Region for the created resources | <code>string</code> | | <code>&#34;europe-west4&#34;</code> |
119+
| [wordpress_password](variables.tf#L88) | Password for the Wordpress user (will be randomly generated by default) | <code>string</code> | | <code>null</code> |
120+
| [wordpress_port](variables.tf#L82) | Port for the Wordpress image (8080 by default) | <code>number</code> | | <code>8080</code> |
121121

122122
## Outputs
123123

124124
| name | description | sensitive |
125125
|---|---|:---:|
126126
| [cloud_run_service](outputs.tf#L17) | CloudRun service URL ||
127-
| [wp_password](outputs.tf#L28) | Wordpress user password ||
128-
| [wp_user](outputs.tf#L23) | Wordpress username | |
127+
| [cloudsql_password](outputs.tf#L23) | CloudSQL password ||
128+
| [wp_password](outputs.tf#L34) | Wordpress user password ||
129+
| [wp_user](outputs.tf#L29) | Wordpress username | |
129130

130131
<!-- END TFDOC -->

blueprints/third-party-solutions/wordpress/cloudrun/main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ module "cloud_run" {
120120

121121
# create a VPC connector for the ClouSQL VPC
122122
vpc_connector_create = {
123-
ip_cidr_range = var.connector_cidr
123+
ip_cidr_range = var.ip_ranges.connector
124124
name = "${local.prefix}wp-connector"
125125
vpc_self_link = module.vpc.self_link
126126
}
@@ -134,7 +134,7 @@ module "vpc" {
134134
name = "${local.prefix}sql-vpc"
135135
subnets = [
136136
{
137-
ip_cidr_range = var.sql_vpc_cidr
137+
ip_cidr_range = var.ip_ranges.sql_vpc
138138
name = "subnet"
139139
region = var.region
140140
secondary_ip_range = {}
@@ -144,7 +144,7 @@ module "vpc" {
144144
# Private Service Access
145145
psa_config = {
146146
ranges = {
147-
cloud-sql = var.psa_cidr
147+
cloud-sql = var.ip_ranges.psa
148148
}
149149
routes = null
150150
}
@@ -156,7 +156,7 @@ module "firewall" {
156156
source = "../../../../modules/net-vpc-firewall"
157157
project_id = module.project.project_id
158158
network = module.vpc.name
159-
admin_ranges = [var.sql_vpc_cidr]
159+
admin_ranges = [var.ip_ranges.sql_vpc]
160160
}
161161

162162

blueprints/third-party-solutions/wordpress/cloudrun/variables.tf

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,19 @@ variable "cloudsql_password" {
2727
default = null
2828
}
2929

30-
variable "connector_cidr" {
31-
type = string
32-
description = "CIDR block for the VPC serverless connector (10.8.0.0/28 by default)"
33-
default = "10.8.0.0/28"
30+
# PSA: documentation: https://cloud.google.com/vpc/docs/configure-private-services-access#allocating-range
31+
variable "ip_ranges" {
32+
description = "CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC"
33+
type = object({
34+
connector = string
35+
psa = string
36+
sql_vpc = string
37+
})
38+
default = {
39+
connector = "10.8.0.0/28"
40+
psa = "10.60.0.0/24"
41+
sql_vpc = "10.0.0.0/20"
42+
}
3443
}
3544

3645
variable "prefix" {
@@ -59,25 +68,12 @@ variable "project_id" {
5968
type = string
6069
}
6170

62-
# Documentation: https://cloud.google.com/vpc/docs/configure-private-services-access#allocating-range
63-
variable "psa_cidr" {
64-
type = string
65-
description = "CIDR block for Private Service Access for CloudSQL (10.60.0.0/24 by default)"
66-
default = "10.60.0.0/24"
67-
}
68-
6971
variable "region" {
7072
type = string
7173
description = "Region for the created resources"
7274
default = "europe-west4"
7375
}
7476

75-
variable "sql_vpc_cidr" {
76-
type = string
77-
description = "CIDR block for the VPC for the CloudSQL (10.0.0.0/20 by default)"
78-
default = "10.0.0.0/20"
79-
}
80-
8177
variable "wordpress_image" {
8278
type = string
8379
description = "Image to run with Cloud Run, starts with \"gcr.io\""

0 commit comments

Comments
 (0)