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 reporting UI to terraform #1594

Open
wants to merge 1 commit 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/main/terraform/gcloud/cmms/reporting_ui.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 The Cross-Media Measurement Authors
#
# 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.

module "reporting_v2_cluster" {
source = "../modules/reporting_ui"

iam_service_account_name_ui = "reporting-ui"
iam_service_account_name_gateway = "reporting-bff"
iam_service_account_name_grpc = "reporting-gateway"
}
3 changes: 3 additions & 0 deletions src/main/terraform/gcloud/modules/reporting-ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Reporting System

Reusable module for the Halo Reporting UI system on Google Cloud.
56 changes: 56 additions & 0 deletions src/main/terraform/gcloud/modules/reporting-ui/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Copyright 2024 The Cross-Media Measurement Authors
#
# 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.

data "google_client_config" "default" {}

locals {
storage_bucket_location = var.storage_bucket_location == null ? data.google_client_config.default.region : var.storage_bucket_location
}

module "reporting_ui_user" {
source = "../workload-identity-user"

k8s_service_account_name = "reporting-ui-server"
iam_service_account_name = var.iam_service_account_name_ui
iam_service_account_description = "Reporting UI server."
}

module "reporting_gateway_user" {
source = "../workload-identity-user"

k8s_service_account_name = "reporting-gateway-server"
iam_service_account_name = var.iam_service_account_name_gateway
iam_service_account_description = "Reporting Gateway server."
}

module "reporting_grpc_user" {
source = "../workload-identity-user"

k8s_service_account_name = "reporting-grpc-server"
iam_service_account_name = var.iam_service_account_name_grpc
iam_service_account_description = "Reporting GRPC server."
}

module "ui_server_bucket" {
source = "../storage-bucket"

name = var.storage_bucket_name
location = local.storage_bucket_location
}

resource "google_storage_bucket_iam_member" "ui_server_bucket_member" {
bucket = module.ui_server_bucket.storage_bucket.name
role = "roles/storage.objectViewer"
member = module.reporting_ui_user.iam_service_account.member
}
43 changes: 43 additions & 0 deletions src/main/terraform/gcloud/modules/reporting-ui/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2023 The Cross-Media Measurement Authors
#
# 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 "iam_service_account_name_ui" {
description = "IAM `google_service_account.name` for the UI server."
type = string
nullable = false
}

variable "iam_service_account_name_gateway" {
description = "IAM `google_service_account.name` for the Gateway server."
type = string
nullable = false
}

variable "iam_service_account_name_grpc" {
description = "IAM `google_service_account.name` for the GRPC server."
type = string
nullable = false
}

variable "storage_bucket_name" {
description = "Name of Google Cloud Storage bucket where the website and server files will be stored."
type = string
nullable = false
}

variable "storage_bucket_location" {
description = "Location of the Google Cloud Storage bucket. Defaults to provider region."
type = string
default = null
}
22 changes: 22 additions & 0 deletions src/main/terraform/gcloud/modules/reporting-ui/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2023 The Cross-Media Measurement Authors
#
# 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.

terraform {
required_providers {
google = {
source = "hashicorp/google"
version = ">= 5.4.0"
}
}
}