diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c23ce0ca7c5d0c05b3704ac382c6efd9a9bc0b8b..49e5c96c3d29c88ca31a3fc43b5f8e6e8d6d36a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -71,7 +71,7 @@ build: - $API_BASE_URL_PATH name: '${CI_JOB_NAME}_${CI_JOB_ID}' #when: on_failure # can't do that for api base url, but can't define multiple artifacts - expire_in: 1 month + expire_in: 1 week variables: ENVIRONMENT_ID: $CI_ENVIRONMENT_SLUG script: diff --git a/terraform/common/init.tf b/terraform/common/init.tf index 1d04961ac239f05bd972e8065a0c3ac14b1c51dd..8498779e964ace247ffd5a434d6e33347e4b888f 100644 --- a/terraform/common/init.tf +++ b/terraform/common/init.tf @@ -23,9 +23,9 @@ data "terraform_remote_state" "okuna-common_state" { # provider google including beta features provider "google" { - region = "europe-north1" + region = local.default_region } provider "google-beta" { - region = "europe-north1" + region = local.default_region } diff --git a/terraform/common/vars.tf b/terraform/common/vars.tf new file mode 100644 index 0000000000000000000000000000000000000000..1c12ce4019d313359dfe5c31ca6df20b8d0cd440 --- /dev/null +++ b/terraform/common/vars.tf @@ -0,0 +1,3 @@ +locals { + default_region = data.terraform_remote_state.holi_infra_state.outputs.default_region +} diff --git a/terraform/environments/function.tf b/terraform/environments/function.tf index 54581ae99c63a3010f6b387ab906f75c738c61c7..aab5e194def68a33824e80e373aa84b4cd1ffdea 100644 --- a/terraform/environments/function.tf +++ b/terraform/environments/function.tf @@ -1,27 +1,13 @@ # see https://cloud.google.com/functions/docs/tutorials/terraform-pubsub -locals { - # predefined environment names are staging, production, and <branchname> - environment = terraform.workspace - environment_name = trim(substr(local.environment, 0, 22), ".-") # limits the length of the name that it fits constraints google imposes for some resources, e.g. project ids - - default_location = "europe-north1" -} - resource "random_id" "main" { byte_length = 2 prefix = "chat-integration-${local.environment_name}-" } -resource "google_storage_bucket" "sources" { - project = data.terraform_remote_state.holi_infra_state.outputs.shared_project_id - name = random_id.main.hex - location = local.default_location - uniform_bucket_level_access = true -} resource "google_storage_bucket_object" "function_source" { - name = "receiveEvent.zip" - bucket = google_storage_bucket.sources.name + name = "${random_id.main.hex}/receiveEvent.zip" + bucket = data.terraform_remote_state.holi_infra_state.outputs.gcf_sources_upload_bucket_name source = "../../receiveEvent.zip" } @@ -38,7 +24,7 @@ data "google_secret_manager_secret" "chat_admin_access_token" { resource "google_cloudfunctions2_function" "holi-chat-integration" { project = data.terraform_remote_state.holi_infra_state.outputs.shared_project_id name = random_id.main.hex - location = local.default_location + location = local.default_region build_config { runtime = "nodejs18" @@ -46,7 +32,7 @@ resource "google_cloudfunctions2_function" "holi-chat-integration" { source { storage_source { - bucket = google_storage_bucket.sources.name + bucket = data.terraform_remote_state.holi_infra_state.outputs.gcf_sources_upload_bucket_name object = google_storage_bucket_object.function_source.name } } diff --git a/terraform/environments/init.tf b/terraform/environments/init.tf index 101f39d73a85bda179da5856e4845e20ccddbbe0..deaaf8ab2132e5d181091946cefce630ee555f3b 100644 --- a/terraform/environments/init.tf +++ b/terraform/environments/init.tf @@ -31,9 +31,9 @@ data "terraform_remote_state" "okuna_common_state" { # provider google including beta features provider "google" { - region = "europe-north1" + region = local.default_region } provider "google-beta" { - region = "europe-north1" + region = local.default_region } diff --git a/terraform/environments/vars.tf b/terraform/environments/vars.tf new file mode 100644 index 0000000000000000000000000000000000000000..de1465dcce36f9162c773c6053a710fa0711e2f8 --- /dev/null +++ b/terraform/environments/vars.tf @@ -0,0 +1,7 @@ +locals { + # predefined environment names are staging, production, and <branchname> + environment = terraform.workspace + environment_name = trim(substr(local.environment, 0, 22), ".-") # limits the length of the name that it fits constraints google imposes for some resources, e.g. project ids + + default_region = data.terraform_remote_state.holi_infra_state.outputs.default_region +}