Repository navigation
Expand file tree
/
Copy pathfunction.tf
More file actions
66 lines (57 loc) · 2.19 KB
/
Copy pathfunction.tf
File metadata and controls
66 lines (57 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
locals {
function_name = local.resource_name
use_bootstrap_artifact = local.app_version == ""
effective_runtime = local.use_bootstrap_artifact ? "go125" : var.runtime
effective_entrypoint = local.use_bootstrap_artifact ? "bootstrap" : var.entrypoint
effective_source_key = local.use_bootstrap_artifact ? google_storage_bucket_object.bootstrap.name : local.current_artifact_key
}
resource "google_cloudfunctions2_function" "function" {
depends_on = [
google_project_service.run,
google_project_service.cloudbuild,
google_project_service.function,
google_project_service.artifact_registry,
google_project_iam_member.builder_build,
google_project_iam_member.builder_publish_artifacts,
google_project_iam_member.builder_code_access,
]
name = local.function_name
location = local.region
description = "${local.resource_name} - Managed by Nullstone"
labels = local.labels
build_config {
runtime = local.effective_runtime
entry_point = local.effective_entrypoint
service_account = google_service_account.builder.id
environment_variables = {}
source {
storage_source {
bucket = google_storage_bucket.source_code.name
object = local.effective_source_key
}
}
}
service_config {
service_account_email = google_service_account.app.email
available_cpu = var.cpu
available_memory = var.memory
timeout_seconds = var.timeout
max_instance_count = var.max_instances
max_instance_request_concurrency = var.max_request_concurrency
all_traffic_on_latest_revision = true
ingress_settings = "ALLOW_INTERNAL_AND_GCLB"
vpc_connector_egress_settings = "ALL_TRAFFIC"
vpc_connector = local.vpc_access_connector_id
environment_variables = local.function_env_vars
dynamic "secret_environment_variables" {
for_each = local.all_secrets
iterator = secretRef
content {
key = secretRef.key
project_id = local.project_id
secret = secretRef.value
version = "latest"
}
}
}
}