Added min_instances, max_instances, min_throughput and max_throughtpu… (#2706)
* Added min_instances, max_instances, min_throughput and max_throughtput to connector configuration * refactor interface, also implement in v1 module * fix blueprint --------- Co-authored-by: Ludo <ludomagno@google.com>
This commit is contained in:
@@ -172,6 +172,7 @@ module "cf-healthchecker" {
|
||||
vpc_connector_config = {
|
||||
ip_cidr_range = "10.132.0.0/28"
|
||||
network = "vpc"
|
||||
instances = {}
|
||||
}
|
||||
iam = {
|
||||
"roles/cloudfunctions.invoker" = [module.service-account-scheduler.iam_email]
|
||||
|
||||
@@ -399,7 +399,7 @@ module "cf-http" {
|
||||
| [service_account_create](variables.tf#L194) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
|
||||
| [trigger_config](variables.tf#L200) | Function trigger configuration. Leave null for HTTP trigger. | <code title="object({ event = string resource = string retry = optional(bool) })">object({…})</code> | | <code>null</code> |
|
||||
| [vpc_connector](variables.tf#L210) | VPC connector configuration. Set create to 'true' if a new connector needs to be created. | <code title="object({ create = bool name = string egress_settings = string })">object({…})</code> | | <code>null</code> |
|
||||
| [vpc_connector_config](variables.tf#L220) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object({ ip_cidr_range = string network = string })">object({…})</code> | | <code>null</code> |
|
||||
| [vpc_connector_config](variables.tf#L220) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object({ ip_cidr_range = string network = string instances = optional(object({ max = optional(number) min = optional(number, 2) })) throughput = optional(object({ max = optional(number, 300) min = optional(number, 200) })) })">object({…})</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -42,12 +42,16 @@ locals {
|
||||
}
|
||||
|
||||
resource "google_vpc_access_connector" "connector" {
|
||||
count = try(var.vpc_connector.create, false) == false ? 0 : 1
|
||||
project = var.project_id
|
||||
name = var.vpc_connector.name
|
||||
region = var.region
|
||||
ip_cidr_range = var.vpc_connector_config.ip_cidr_range
|
||||
network = var.vpc_connector_config.network
|
||||
count = try(var.vpc_connector.create, false) == true ? 1 : 0
|
||||
project = var.project_id
|
||||
name = var.vpc_connector.name
|
||||
region = var.region
|
||||
ip_cidr_range = var.vpc_connector_config.ip_cidr_range
|
||||
network = var.vpc_connector_config.network
|
||||
max_instances = try(var.vpc_connector_config.instances.max, null)
|
||||
min_instances = try(var.vpc_connector_config.instances.min, null)
|
||||
max_throughput = try(var.vpc_connector_config.throughput.max, null)
|
||||
min_throughput = try(var.vpc_connector_config.throughput.min, null)
|
||||
}
|
||||
|
||||
resource "google_cloudfunctions_function" "function" {
|
||||
|
||||
@@ -222,6 +222,22 @@ variable "vpc_connector_config" {
|
||||
type = object({
|
||||
ip_cidr_range = string
|
||||
network = string
|
||||
instances = optional(object({
|
||||
max = optional(number)
|
||||
min = optional(number, 2)
|
||||
}))
|
||||
throughput = optional(object({
|
||||
max = optional(number, 300)
|
||||
min = optional(number, 200)
|
||||
}))
|
||||
})
|
||||
default = null
|
||||
validation {
|
||||
condition = (
|
||||
var.vpc_connector_config == null ||
|
||||
try(var.vpc_connector_config.instances, null) != null ||
|
||||
try(var.vpc_connector_config.throughput, null) != null
|
||||
)
|
||||
error_message = "VPC connector must specify either instances or throughput."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ module "cf-http" {
|
||||
| [service_account_create](variables.tf#L191) | Auto-create service account. | <code>bool</code> | | <code>false</code> |
|
||||
| [trigger_config](variables.tf#L197) | Function trigger configuration. Leave null for HTTP trigger. | <code title="object({ event_type = string pubsub_topic = optional(string) region = optional(string) event_filters = optional(list(object({ attribute = string value = string operator = optional(string) })), []) service_account_email = optional(string) service_account_create = optional(bool, false) retry_policy = optional(string, "RETRY_POLICY_DO_NOT_RETRY") # default to avoid permadiff })">object({…})</code> | | <code>null</code> |
|
||||
| [vpc_connector](variables.tf#L215) | VPC connector configuration. Set create to 'true' if a new connector needs to be created. | <code title="object({ create = bool name = string egress_settings = string })">object({…})</code> | | <code>null</code> |
|
||||
| [vpc_connector_config](variables.tf#L225) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object({ ip_cidr_range = string network = string })">object({…})</code> | | <code>null</code> |
|
||||
| [vpc_connector_config](variables.tf#L225) | VPC connector network configuration. Must be provided if new VPC connector is being created. | <code title="object({ ip_cidr_range = string network = string instances = optional(object({ max = optional(number) min = optional(number, 2) })) throughput = optional(object({ max = optional(number, 300) min = optional(number, 200) })) })">object({…})</code> | | <code>null</code> |
|
||||
|
||||
## Outputs
|
||||
|
||||
|
||||
@@ -50,12 +50,16 @@ locals {
|
||||
}
|
||||
|
||||
resource "google_vpc_access_connector" "connector" {
|
||||
count = try(var.vpc_connector.create, false) == true ? 1 : 0
|
||||
project = var.project_id
|
||||
name = var.vpc_connector.name
|
||||
region = var.region
|
||||
ip_cidr_range = var.vpc_connector_config.ip_cidr_range
|
||||
network = var.vpc_connector_config.network
|
||||
count = try(var.vpc_connector.create, false) == true ? 1 : 0
|
||||
project = var.project_id
|
||||
name = var.vpc_connector.name
|
||||
region = var.region
|
||||
ip_cidr_range = var.vpc_connector_config.ip_cidr_range
|
||||
network = var.vpc_connector_config.network
|
||||
max_instances = try(var.vpc_connector_config.instances.max, null)
|
||||
min_instances = try(var.vpc_connector_config.instances.min, null)
|
||||
max_throughput = try(var.vpc_connector_config.throughput.max, null)
|
||||
min_throughput = try(var.vpc_connector_config.throughput.min, null)
|
||||
}
|
||||
|
||||
resource "google_cloudfunctions2_function" "function" {
|
||||
|
||||
@@ -227,6 +227,22 @@ variable "vpc_connector_config" {
|
||||
type = object({
|
||||
ip_cidr_range = string
|
||||
network = string
|
||||
instances = optional(object({
|
||||
max = optional(number)
|
||||
min = optional(number, 2)
|
||||
}))
|
||||
throughput = optional(object({
|
||||
max = optional(number, 300)
|
||||
min = optional(number, 200)
|
||||
}))
|
||||
})
|
||||
default = null
|
||||
validation {
|
||||
condition = (
|
||||
var.vpc_connector_config == null ||
|
||||
try(var.vpc_connector_config.instances, null) != null ||
|
||||
try(var.vpc_connector_config.throughput, null) != null
|
||||
)
|
||||
error_message = "VPC connector must specify either instances or throughput."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user