connector creation in a variable
This commit is contained in:
parent
e9779e30ed
commit
07f89e0aa0
|
@ -110,17 +110,18 @@ The above command will delete the associated resources so there will be no billa
|
||||||
|
|
||||||
| name | description | type | required | default |
|
| name | description | type | required | default |
|
||||||
|---|---|:---:|:---:|:---:|
|
|---|---|:---:|:---:|:---:|
|
||||||
| [project_id](variables.tf#L66) | Project id, references existing project if `project_create` is null. | <code>string</code> | ✓ | |
|
| [project_id](variables.tf#L72) | Project id, references existing project if `project_create` is null. | <code>string</code> | ✓ | |
|
||||||
| [wordpress_image](variables.tf#L77) | Image to run with Cloud Run, starts with \"gcr.io\" | <code>string</code> | ✓ | |
|
| [wordpress_image](variables.tf#L83) | Image to run with Cloud Run, starts with \"gcr.io\" | <code>string</code> | ✓ | |
|
||||||
| [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>"allUsers"</code> |
|
| [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>"allUsers"</code> |
|
||||||
| [cloudsql_password](variables.tf#L24) | CloudSQL password (will be randomly generated by default) | <code>string</code> | | <code>null</code> |
|
| [cloudsql_password](variables.tf#L24) | CloudSQL password (will be randomly generated by default) | <code>string</code> | | <code>null</code> |
|
||||||
| [ip_ranges](variables.tf#L31) | CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC | <code title="object({ connector = string psa = string sql_vpc = string })">object({…})</code> | | <code title="{ connector = "10.8.0.0/28" psa = "10.60.0.0/24" sql_vpc = "10.0.0.0/20" }">{…}</code> |
|
| [create_connector](variables.tf#L30) | Should a VPC serverless connector be created or not | <code>bool</code> | | <code>true</code> |
|
||||||
| [prefix](variables.tf#L45) | Unique prefix used for resource names. Not used for project if 'project_create' is null. | <code>string</code> | | <code>""</code> |
|
| [ip_ranges](variables.tf#L37) | CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC | <code title="object({ connector = string psa = string sql_vpc = string })">object({…})</code> | | <code title="{ connector = "10.8.0.0/28" psa = "10.60.0.0/24" sql_vpc = "10.0.0.0/20" }">{…}</code> |
|
||||||
| [principals](variables.tf#L51) | List of users to give rights to (CloudSQL admin, client and instanceUser, Logging admin, Service Account User and TokenCreator), eg 'user@domain.com'. | <code>list(string)</code> | | <code>[]</code> |
|
| [prefix](variables.tf#L51) | Unique prefix used for resource names. Not used for project if 'project_create' is null. | <code>string</code> | | <code>""</code> |
|
||||||
| [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({ billing_account_id = string parent = string })">object({…})</code> | | <code>null</code> |
|
| [principals](variables.tf#L57) | List of users to give rights to (CloudSQL admin, client and instanceUser, Logging admin, Service Account User and TokenCreator), eg 'user@domain.com'. | <code>list(string)</code> | | <code>[]</code> |
|
||||||
| [region](variables.tf#L71) | Region for the created resources | <code>string</code> | | <code>"europe-west4"</code> |
|
| [project_create](variables.tf#L63) | Provide values if project creation is needed, uses existing project if null. Parent is in 'folders/nnn' or 'organizations/nnn' format. | <code title="object({ billing_account_id = string parent = string })">object({…})</code> | | <code>null</code> |
|
||||||
| [wordpress_password](variables.tf#L88) | Password for the Wordpress user (will be randomly generated by default) | <code>string</code> | | <code>null</code> |
|
| [region](variables.tf#L77) | Region for the created resources | <code>string</code> | | <code>"europe-west4"</code> |
|
||||||
| [wordpress_port](variables.tf#L82) | Port for the Wordpress image (8080 by default) | <code>number</code> | | <code>8080</code> |
|
| [wordpress_password](variables.tf#L94) | Password for the Wordpress user (will be randomly generated by default) | <code>string</code> | | <code>null</code> |
|
||||||
|
| [wordpress_port](variables.tf#L88) | Port for the Wordpress image | <code>number</code> | | <code>8080</code> |
|
||||||
|
|
||||||
## Outputs
|
## Outputs
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ module "firewall" {
|
||||||
|
|
||||||
# create a VPC connector for the ClouSQL VPC
|
# create a VPC connector for the ClouSQL VPC
|
||||||
resource "google_vpc_access_connector" "connector" {
|
resource "google_vpc_access_connector" "connector" {
|
||||||
|
count = var.create_connector ? 1 : 0
|
||||||
project = module.project.project_id
|
project = module.project.project_id
|
||||||
name = "${local.prefix}wp-connector"
|
name = "${local.prefix}wp-connector"
|
||||||
region = var.region
|
region = var.region
|
||||||
|
|
|
@ -113,8 +113,8 @@ module "cloud_run" {
|
||||||
cloudsql_instances = [module.cloudsql.connection_name]
|
cloudsql_instances = [module.cloudsql.connection_name]
|
||||||
vpcaccess_connector = null
|
vpcaccess_connector = null
|
||||||
# allow all traffic
|
# allow all traffic
|
||||||
vpcaccess_egress = "all-traffic"
|
vpcaccess_egress = "all-traffic"
|
||||||
vpcaccess_connector = google_vpc_access_connector.connector.self_link
|
vpcaccess_connector = google_vpc_access_connector.connector.0.self_link
|
||||||
}
|
}
|
||||||
ingress_settings = "all"
|
ingress_settings = "all"
|
||||||
}
|
}
|
|
@ -27,6 +27,12 @@ variable "cloudsql_password" {
|
||||||
default = null
|
default = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "create_connector" {
|
||||||
|
type = bool
|
||||||
|
description = "Should a VPC serverless connector be created or not"
|
||||||
|
default = true
|
||||||
|
}
|
||||||
|
|
||||||
# PSA: documentation: https://cloud.google.com/vpc/docs/configure-private-services-access#allocating-range
|
# PSA: documentation: https://cloud.google.com/vpc/docs/configure-private-services-access#allocating-range
|
||||||
variable "ip_ranges" {
|
variable "ip_ranges" {
|
||||||
description = "CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC"
|
description = "CIDR blocks: VPC serverless connector, Private Service Access(PSA) for CloudSQL, CloudSQL VPC"
|
||||||
|
@ -81,7 +87,7 @@ variable "wordpress_image" {
|
||||||
|
|
||||||
variable "wordpress_port" {
|
variable "wordpress_port" {
|
||||||
type = number
|
type = number
|
||||||
description = "Port for the Wordpress image (8080 by default)"
|
description = "Port for the Wordpress image"
|
||||||
default = 8080
|
default = 8080
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue