2020-06-28 23:05:44 -07:00
/ * *
2022-01-01 06:52:31 -08:00
* Copyright 2022 Google LLC
2020-06-28 23:05:44 -07:00
*
* 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 " bucket_config " {
description = " Enable and configure auto-created bucket. Set fields to null to use defaults. "
type = object ( {
2022-11-16 00:31:43 -08:00
location = optional ( string )
lifecycle_delete_age_days = optional ( number )
2020-06-28 23:05:44 -07:00
} )
default = null
}
variable " bucket_name " {
description = " Name of the bucket that will be used for the function code. It will be created with prefix prepended if bucket_config is not null. "
type = string
2023-09-28 03:17:53 -07:00
nullable = false
2020-06-28 23:05:44 -07:00
}
2022-11-15 03:24:59 -08:00
variable " build_worker_pool " {
2022-11-24 09:56:01 -08:00
description = " Build worker pool, in projects/<PROJECT-ID>/locations/<REGION>/workerPools/<POOL_NAME> format. "
2022-11-15 03:24:59 -08:00
type = string
2022-11-15 05:42:19 -08:00
default = null
2022-11-15 03:24:59 -08:00
}
2020-06-28 23:05:44 -07:00
variable " bundle_config " {
2024-06-14 04:44:01 -07:00
description = " Cloud function source. Path can point to a GCS object URI, or a local path. A local path to a zip archive will generate a GCS object using its basename, a folder will be zipped and the GCS object name inferred when not specified. "
2020-06-28 23:05:44 -07:00
type = object ( {
2024-06-14 04:44:01 -07:00
path = string
folder_options = optional ( object ( {
archive_path = optional ( string )
excludes = optional ( list ( string ) )
} ) , { } )
2020-06-28 23:05:44 -07:00
} )
2024-06-14 04:44:01 -07:00
nullable = false
2024-06-14 00:23:49 -07:00
validation {
condition = (
var . bundle_config . path ! = null && (
2024-06-14 04:44:01 -07:00
# GCS object
2024-06-14 00:23:49 -07:00
(
2024-06-14 04:44:01 -07:00
startswith ( var . bundle_config . path , " gs:// " ) &&
2024-06-14 00:23:49 -07:00
endswith ( var . bundle_config . path , " .zip " )
2024-06-14 04:44:01 -07:00
)
| |
# local folder
2024-06-14 00:23:49 -07:00
length ( fileset ( pathexpand ( var . bundle_config . path ) , " **/* " ) ) > 0
2024-06-14 04:44:01 -07:00
| |
# local ZIP archive
(
try ( fileexists ( pathexpand ( var . bundle_config . path ) ) , null ) ! = null &&
endswith ( var . bundle_config . path , " .zip " )
)
2024-06-14 00:23:49 -07:00
)
)
2024-06-14 04:44:01 -07:00
error_message = " Bundle path must be set to a GCS object URI, a local folder or a local zip file. "
2024-06-14 00:23:49 -07:00
}
2020-06-28 23:05:44 -07:00
}
2021-10-19 12:10:43 -07:00
variable " description " {
description = " Optional description. "
type = string
default = " Terraform managed. "
}
2024-01-20 01:40:26 -08:00
variable " docker_repository_id " {
description = " User managed repository created in Artifact Registry. "
type = string
default = null
}
2020-06-28 23:05:44 -07:00
variable " environment_variables " {
description = " Cloud function environment variables. "
type = map ( string )
default = { }
}
variable " function_config " {
2022-11-24 09:56:01 -08:00
description = " Cloud function configuration. Defaults to using main as entrypoint, 1 instance with 256MiB of memory, and 180 second timeout. "
2020-06-28 23:05:44 -07:00
type = object ( {
2022-11-16 00:31:43 -08:00
entry_point = optional ( string , " main " )
instance_count = optional ( number , 1 )
memory_mb = optional ( number , 256 ) # Memory in MB
2023-05-12 04:49:22 -07:00
cpu = optional ( string , " 0.166 " )
2022-11-16 00:31:43 -08:00
runtime = optional ( string , " python310 " )
timeout_seconds = optional ( number , 180 )
2020-06-28 23:05:44 -07:00
} )
default = {
2022-11-16 00:31:43 -08:00
entry_point = " main "
instance_count = 1
memory_mb = 256
2023-05-12 04:49:22 -07:00
cpu = " 0.166 "
2022-11-16 00:31:43 -08:00
runtime = " python310 "
timeout_seconds = 180
2020-06-28 23:05:44 -07:00
}
}
2020-11-05 23:37:44 -08:00
variable " iam " {
description = " IAM bindings for topic in {ROLE => [MEMBERS]} format. "
type = map ( list ( string ) )
default = { }
}
2020-07-23 23:55:58 -07:00
variable " ingress_settings " {
2022-03-28 22:42:15 -07:00
description = " Control traffic that reaches the cloud function. Allowed values are ALLOW_ALL, ALLOW_INTERNAL_AND_GCLB and ALLOW_INTERNAL_ONLY . "
2020-07-23 23:55:58 -07:00
type = string
default = null
}
2024-05-14 05:56:10 -07:00
variable " kms_key " {
description = " Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources in key id format. If specified, you must also provide an artifact registry repository using the docker_repository_id field that was created with the same KMS crypto key. "
type = string
default = null
}
2020-06-28 23:05:44 -07:00
variable " labels " {
2022-01-31 01:45:34 -08:00
description = " Resource labels. "
2020-06-28 23:05:44 -07:00
type = map ( string )
default = { }
}
variable " name " {
description = " Name used for cloud function and associated resources. "
type = string
}
variable " prefix " {
description = " Optional prefix used for resource names. "
type = string
default = null
2022-11-15 06:10:42 -08:00
validation {
condition = var . prefix ! = " "
error_message = " Prefix cannot be empty, please use null instead. "
}
2020-06-28 23:05:44 -07:00
}
variable " project_id " {
description = " Project id used for all resources. "
type = string
}
variable " region " {
description = " Region used for all resources. "
type = string
}
2022-06-16 07:34:46 -07:00
variable " secrets " {
description = " Secret Manager secrets. Key is the variable name or mountpoint, volume versions are in version:path format. "
type = map ( object ( {
is_volume = bool
project_id = number
secret = string
versions = list ( string )
} ) )
nullable = false
default = { }
}
2020-06-28 23:05:44 -07:00
variable " service_account " {
2022-11-12 03:34:09 -08:00
description = " Service account email. Unused if service account is auto-created. "
2020-06-28 23:05:44 -07:00
type = string
default = null
}
variable " service_account_create " {
description = " Auto-create service account. "
type = bool
default = false
}
variable " trigger_config " {
description = " Function trigger configuration. Leave null for HTTP trigger. "
type = object ( {
2023-06-19 03:50:36 -07:00
event_type = string
pubsub_topic = optional ( string )
region = optional ( string )
event_filters = optional ( list ( object ( {
attribute = string
value = string
2023-07-25 06:56:36 -07:00
operator = optional ( string )
2023-06-19 03:50:36 -07:00
} ) ) , [ ] )
service_account_email = optional ( string )
service_account_create = optional ( bool , false )
retry_policy = optional ( string )
2020-06-28 23:05:44 -07:00
} )
2023-06-19 03:50:36 -07:00
default = null
2022-11-18 08:48:16 -08:00
}
2021-11-17 08:24:24 -08:00
variable " vpc_connector " {
2022-01-31 01:45:34 -08:00
description = " VPC connector configuration. Set create to 'true' if a new connector needs to be created. "
2020-07-23 23:55:58 -07:00
type = object ( {
2021-11-17 08:24:24 -08:00
create = bool
2020-07-23 23:55:58 -07:00
name = string
2021-11-17 08:24:24 -08:00
egress_settings = string
} )
default = null
}
variable " vpc_connector_config " {
2022-01-31 01:45:34 -08:00
description = " VPC connector network configuration. Must be provided if new VPC connector is being created. "
2021-11-17 08:24:24 -08:00
type = object ( {
ip_cidr_range = string
network = string
2020-07-23 23:55:58 -07:00
} )
default = null
2024-01-20 01:40:26 -08:00
}