Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloud storage bucket for "website deployment" #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/bootstrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}
Expand Down Expand Up @@ -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!' }}
Expand Down
20 changes: 20 additions & 0 deletions scopes/application/04_webapp_bucket.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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

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"
}
11 changes: 7 additions & 4 deletions scopes/application/variables.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
}