Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added min_instances, max_instances, min_throughput and max_throughtpu… #2706

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion modules/cloud-function-v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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&#40;&#123;&#10; event &#61; string&#10; resource &#61; string&#10; retry &#61; optional&#40;bool&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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&#40;&#123;&#10; create &#61; bool&#10; name &#61; string&#10; egress_settings &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10; instances &#61; optional&#40;object&#40;&#123;&#10; max &#61; optional&#40;number&#41;&#10; min &#61; optional&#40;number, 2&#41;&#10; &#125;&#41;&#41;&#10; throughput &#61; optional&#40;object&#40;&#123;&#10; max &#61; optional&#40;number, 300&#41;&#10; min &#61; optional&#40;number, 200&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs

Expand Down
16 changes: 10 additions & 6 deletions modules/cloud-function-v1/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
16 changes: 16 additions & 0 deletions modules/cloud-function-v1/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
2 changes: 1 addition & 1 deletion modules/cloud-function-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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&#40;&#123;&#10; event_type &#61; string&#10; pubsub_topic &#61; optional&#40;string&#41;&#10; region &#61; optional&#40;string&#41;&#10; event_filters &#61; optional&#40;list&#40;object&#40;&#123;&#10; attribute &#61; string&#10; value &#61; string&#10; operator &#61; optional&#40;string&#41;&#10; &#125;&#41;&#41;, &#91;&#93;&#41;&#10; service_account_email &#61; optional&#40;string&#41;&#10; service_account_create &#61; optional&#40;bool, false&#41;&#10; retry_policy &#61; optional&#40;string, &#34;RETRY_POLICY_DO_NOT_RETRY&#34;&#41; &#35; default to avoid permadiff&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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&#40;&#123;&#10; create &#61; bool&#10; name &#61; string&#10; egress_settings &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</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&#40;&#123;&#10; ip_cidr_range &#61; string&#10; network &#61; string&#10; instances &#61; optional&#40;object&#40;&#123;&#10; max &#61; optional&#40;number&#41;&#10; min &#61; optional&#40;number, 2&#41;&#10; &#125;&#41;&#41;&#10; throughput &#61; optional&#40;object&#40;&#123;&#10; max &#61; optional&#40;number, 300&#41;&#10; min &#61; optional&#40;number, 200&#41;&#10; &#125;&#41;&#41;&#10;&#125;&#41;">object&#40;&#123;&#8230;&#125;&#41;</code> | | <code>null</code> |

## Outputs

Expand Down
16 changes: 10 additions & 6 deletions modules/cloud-function-v2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
16 changes: 16 additions & 0 deletions modules/cloud-function-v2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}