From b0aaadc7fa291f332faa6278a4f9ae4343501146 Mon Sep 17 00:00:00 2001 From: "patrick.siegel" Date: Tue, 29 Oct 2024 15:00:26 +0100 Subject: [PATCH 1/3] Add cloud storage bucket for "website deployment" --- ...{03_setup_dns.tf => 03_public_dns_zone.tf} | 0 scopes/application/04_webapp_bucket.tf | 21 +++++++++++++++++++ scopes/application/variables.tf | 11 ++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) rename scopes/application/{03_setup_dns.tf => 03_public_dns_zone.tf} (100%) create mode 100644 scopes/application/04_webapp_bucket.tf diff --git a/scopes/application/03_setup_dns.tf b/scopes/application/03_public_dns_zone.tf similarity index 100% rename from scopes/application/03_setup_dns.tf rename to scopes/application/03_public_dns_zone.tf diff --git a/scopes/application/04_webapp_bucket.tf b/scopes/application/04_webapp_bucket.tf new file mode 100644 index 0000000..f448799 --- /dev/null +++ b/scopes/application/04_webapp_bucket.tf @@ -0,0 +1,21 @@ +data "google_project" "lpt_proj" { + project_id = var.project_id +} + +resource "google_storage_bucket" "lpt_ui" { + name = var.ui_bucket_name + location = var.gcp_region + project = data.google_project.lpt_proj.project_id + public_access_prevention = "false" + + website { + main_page_suffix = "index.html" + not_found_page = "index.html" + } +} + +resource "google_storage_bucket_iam_member" "public_rule" { + bucket = google_storage_bucket.lpt_ui.name + role = "roles/storage.objectViewer" + member = "allUsers" +} \ No newline at end of file diff --git a/scopes/application/variables.tf b/scopes/application/variables.tf index d346d5d..e26d6b6 100644 --- a/scopes/application/variables.tf +++ b/scopes/application/variables.tf @@ -1,7 +1,4 @@ -variable "github_token" { - description = "Github token to access and change ressources through the API" - type = string -} + variable "project_id" { description = "Project ID to apply and identify infrastructure code" @@ -12,4 +9,10 @@ variable "gcp_region" { description = "Region the infrastructure should be deployed in" type = string default = "europe-west1" +} + +variable "ui_bucket_name" { + description = "Name of cloud storage bucket for UI hosting" + type = string + default = "lpt-ui" } \ No newline at end of file From 7bb308280942a7d3ff35806f4cd37de91e0f46a1 Mon Sep 17 00:00:00 2001 From: "patrick.siegel" Date: Tue, 29 Oct 2024 15:28:10 +0100 Subject: [PATCH 2/3] Cleanse workflow --- .github/workflows/bootstrap.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/bootstrap.yaml b/.github/workflows/bootstrap.yaml index 5cb4c69..c65dbb1 100644 --- a/.github/workflows/bootstrap.yaml +++ b/.github/workflows/bootstrap.yaml @@ -149,7 +149,6 @@ jobs: terraform -chdir="$TF_WORK_DIR" apply -input=false tfplan terraform output - plan-apply-application: name: Plan and potentially apply for scope application infra if: ${{ github.event.inputs.environment == 'dev' && github.event.inputs.scope == 'application_infrastructure'}} @@ -179,7 +178,6 @@ jobs: run: | terraform -chdir="$TF_WORK_DIR" plan -input=false -out=tfplan \ -var-file "../../environments/dev.tfvars" \ - -var "github_token=$GH_API_TOKEN" \ -var "project_id=$PROJECT_ID" - name: terraform apply if: ${{ github.event.inputs.apply == 'apply!' }} From 565acf7c35cb27771d3eaec4787a603ecc6e4445 Mon Sep 17 00:00:00 2001 From: "patrick.siegel" Date: Tue, 29 Oct 2024 16:05:57 +0100 Subject: [PATCH 3/3] Remove unknown instruction --- scopes/application/04_webapp_bucket.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/scopes/application/04_webapp_bucket.tf b/scopes/application/04_webapp_bucket.tf index f448799..25da992 100644 --- a/scopes/application/04_webapp_bucket.tf +++ b/scopes/application/04_webapp_bucket.tf @@ -6,7 +6,6 @@ resource "google_storage_bucket" "lpt_ui" { name = var.ui_bucket_name location = var.gcp_region project = data.google_project.lpt_proj.project_id - public_access_prevention = "false" website { main_page_suffix = "index.html"