2023-12-04 11:20:46 -08:00
|
|
|
/**
|
|
|
|
* Copyright 2023 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
variable "containers" {
|
2023-12-13 11:23:36 -08:00
|
|
|
description = "Containers in name => attributes format."
|
2023-12-04 11:20:46 -08:00
|
|
|
type = map(object({
|
|
|
|
image = string
|
|
|
|
command = optional(list(string))
|
2023-12-13 11:23:36 -08:00
|
|
|
args = optional(list(string))
|
|
|
|
env = optional(map(string))
|
2023-12-04 11:20:46 -08:00
|
|
|
env_from_key = optional(map(object({
|
2023-12-13 11:23:36 -08:00
|
|
|
secret = string
|
|
|
|
version = string
|
|
|
|
})))
|
2023-12-04 11:20:46 -08:00
|
|
|
liveness_probe = optional(object({
|
2023-12-13 11:23:36 -08:00
|
|
|
grpc = optional(object({
|
|
|
|
port = optional(number)
|
|
|
|
service = optional(string)
|
|
|
|
}))
|
|
|
|
http_get = optional(object({
|
|
|
|
http_headers = optional(map(string))
|
|
|
|
path = optional(string)
|
|
|
|
}))
|
2023-12-04 11:20:46 -08:00
|
|
|
failure_threshold = optional(number)
|
|
|
|
initial_delay_seconds = optional(number)
|
|
|
|
period_seconds = optional(number)
|
|
|
|
timeout_seconds = optional(number)
|
|
|
|
}))
|
|
|
|
ports = optional(map(object({
|
|
|
|
container_port = optional(number)
|
|
|
|
name = optional(string)
|
2023-12-13 11:23:36 -08:00
|
|
|
})))
|
2023-12-04 11:20:46 -08:00
|
|
|
resources = optional(object({
|
|
|
|
limits = optional(object({
|
|
|
|
cpu = string
|
|
|
|
memory = string
|
|
|
|
}))
|
2023-12-13 11:23:36 -08:00
|
|
|
cpu_idle = optional(bool)
|
|
|
|
startup_cpu_boost = optional(bool)
|
2023-12-04 11:20:46 -08:00
|
|
|
}))
|
|
|
|
startup_probe = optional(object({
|
2023-12-13 11:23:36 -08:00
|
|
|
grpc = optional(object({
|
|
|
|
port = optional(number)
|
|
|
|
service = optional(string)
|
|
|
|
}))
|
|
|
|
http_get = optional(object({
|
|
|
|
http_headers = optional(map(string))
|
|
|
|
path = optional(string)
|
|
|
|
}))
|
|
|
|
tcp_socket = optional(object({
|
|
|
|
port = optional(number)
|
|
|
|
}))
|
2023-12-04 11:20:46 -08:00
|
|
|
failure_threshold = optional(number)
|
|
|
|
initial_delay_seconds = optional(number)
|
|
|
|
period_seconds = optional(number)
|
|
|
|
timeout_seconds = optional(number)
|
|
|
|
}))
|
2023-12-13 11:23:36 -08:00
|
|
|
volume_mounts = optional(map(string))
|
2023-12-04 11:20:46 -08:00
|
|
|
}))
|
|
|
|
default = {}
|
|
|
|
nullable = false
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "eventarc_triggers" {
|
|
|
|
description = "Event arc triggers for different sources."
|
|
|
|
type = object({
|
|
|
|
audit_log = optional(map(object({
|
|
|
|
method = string
|
|
|
|
service = string
|
2023-12-13 11:23:36 -08:00
|
|
|
})))
|
|
|
|
pubsub = optional(map(string))
|
2023-12-04 11:20:46 -08:00
|
|
|
service_account_email = optional(string)
|
|
|
|
service_account_create = optional(bool, false)
|
|
|
|
})
|
|
|
|
default = {}
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "iam" {
|
|
|
|
description = "IAM bindings for Cloud Run service in {ROLE => [MEMBERS]} format."
|
|
|
|
type = map(list(string))
|
|
|
|
default = {}
|
|
|
|
}
|
|
|
|
|
2023-12-13 11:23:36 -08:00
|
|
|
variable "ingress" {
|
2023-12-04 11:20:46 -08:00
|
|
|
description = "Ingress settings."
|
|
|
|
type = string
|
|
|
|
default = null
|
|
|
|
validation {
|
2023-12-13 11:23:36 -08:00
|
|
|
condition = (
|
|
|
|
var.ingress == null ? true : contains(
|
|
|
|
["INGRESS_TRAFFIC_ALL", "INGRESS_TRAFFIC_INTERNAL_ONLY",
|
|
|
|
"INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER"], var.ingress)
|
2023-12-04 11:20:46 -08:00
|
|
|
)
|
2023-12-13 11:23:36 -08:00
|
|
|
error_message = <<EOF
|
|
|
|
Ingress should be one of INGRESS_TRAFFIC_ALL, INGRESS_TRAFFIC_INTERNAL_ONLY,
|
|
|
|
INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER.
|
|
|
|
EOF
|
2023-12-04 11:20:46 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "labels" {
|
|
|
|
description = "Resource labels."
|
|
|
|
type = map(string)
|
|
|
|
default = {}
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "launch_stage" {
|
|
|
|
description = "The launch stage as defined by Google Cloud Platform Launch Stages."
|
|
|
|
type = string
|
|
|
|
default = null
|
|
|
|
validation {
|
2023-12-13 11:23:36 -08:00
|
|
|
condition = (
|
|
|
|
var.launch_stage == null ? true : contains(
|
|
|
|
["UNIMPLEMENTED", "PRELAUNCH", "EARLY_ACCESS", "ALPHA", "BETA",
|
|
|
|
"GA", "DEPRECATED"], var.launch_stage)
|
2023-12-04 11:20:46 -08:00
|
|
|
)
|
2023-12-13 11:23:36 -08:00
|
|
|
error_message = <<EOF
|
|
|
|
The launch stage should be one of UNIMPLEMENTED, PRELAUNCH, EARLY_ACCESS, ALPHA,
|
|
|
|
BETA, GA, DEPRECATED.
|
|
|
|
EOF
|
2023-12-04 11:20:46 -08:00
|
|
|
}
|
|
|
|
}
|
2023-12-13 11:23:36 -08:00
|
|
|
|
2023-12-04 11:20:46 -08:00
|
|
|
variable "name" {
|
2023-12-13 11:23:36 -08:00
|
|
|
description = "Name used for Cloud Run service."
|
2023-12-04 11:20:46 -08:00
|
|
|
type = string
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "prefix" {
|
|
|
|
description = "Optional prefix used for resource names."
|
|
|
|
type = string
|
|
|
|
default = null
|
|
|
|
validation {
|
|
|
|
condition = var.prefix != ""
|
|
|
|
error_message = "Prefix cannot be empty, please use null instead."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "project_id" {
|
|
|
|
description = "Project id used for all resources."
|
|
|
|
type = string
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "region" {
|
|
|
|
description = "Region used for all resources."
|
|
|
|
type = string
|
|
|
|
default = "europe-west1"
|
|
|
|
}
|
|
|
|
|
2023-12-13 11:23:36 -08:00
|
|
|
variable "revision" {
|
|
|
|
description = "Revision template configurations."
|
2023-12-04 11:20:46 -08:00
|
|
|
type = object({
|
2023-12-13 11:23:36 -08:00
|
|
|
name = optional(string)
|
|
|
|
gen2_execution_environment = optional(bool)
|
|
|
|
max_concurrency = optional(number)
|
|
|
|
max_instance_count = optional(number)
|
|
|
|
min_instance_count = optional(number)
|
|
|
|
vpc_access = optional(object({
|
|
|
|
connector = optional(string)
|
|
|
|
egress = optional(string)
|
|
|
|
subnet = optional(string)
|
|
|
|
tags = optional(list(string))
|
2023-12-04 11:20:46 -08:00
|
|
|
}))
|
2023-12-13 11:23:36 -08:00
|
|
|
timeout = optional(string)
|
2023-12-04 11:20:46 -08:00
|
|
|
})
|
|
|
|
default = {}
|
|
|
|
nullable = false
|
2023-12-13 11:23:36 -08:00
|
|
|
validation {
|
|
|
|
condition = (
|
|
|
|
try(var.revision.vpc_access.egress, null) == null ? true : contains(
|
|
|
|
["ALL_TRAFFIC", "PRIVATE_RANGES_ONLY"], var.revision.vpc_access.egress)
|
|
|
|
)
|
|
|
|
error_message = "Egress should be one of ALL_TRAFFIC, PRIVATE_RANGES_ONLY."
|
|
|
|
}
|
2023-12-04 11:20:46 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
variable "service_account" {
|
|
|
|
description = "Service account email. Unused if service account is auto-created."
|
|
|
|
type = string
|
|
|
|
default = null
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "service_account_create" {
|
|
|
|
description = "Auto-create service account."
|
|
|
|
type = bool
|
|
|
|
default = false
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "volumes" {
|
|
|
|
description = "Named volumes in containers in name => attributes format."
|
|
|
|
type = map(object({
|
2023-12-13 11:23:36 -08:00
|
|
|
secret = optional(object({
|
2023-12-18 02:42:57 -08:00
|
|
|
name = string
|
2023-12-13 11:23:36 -08:00
|
|
|
default_mode = optional(string)
|
|
|
|
path = optional(string)
|
|
|
|
version = optional(string)
|
|
|
|
mode = optional(string)
|
|
|
|
}))
|
|
|
|
cloud_sql_instances = optional(list(string))
|
|
|
|
empty_dir_size = optional(string)
|
2023-12-04 11:20:46 -08:00
|
|
|
}))
|
|
|
|
default = {}
|
|
|
|
nullable = false
|
|
|
|
}
|