Skip to content

Commit

Permalink
Adds a new "foundations" module (#71)
Browse files Browse the repository at this point in the history
* Adds a new "common" submodule for generic resources

We currently have submodules specific to certain related infrastructure in GCP
(e.g., platform-cluster, data-pipeline). There are quite a lot of resources in
GCP that do not fall neatly into one piece of infrastructure, or that may be
used by multiple things. This "common" submodule is a place to defined such
resources.

* Adds new common module to mlab-staging and mlab-oti projects

* Renames module "common" to "foundations"

"common" is too generic a word and maybe too broad, and possibly a reserved
sort of word in some contexts.
  • Loading branch information
nkinkade committed Mar 12, 2024
1 parent 3a30053 commit a3690e5
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mlab-oti/foundations.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "foundations" {
source = "../modules/foundations"

providers = {
google = google.foundations
}
}

8 changes: 8 additions & 0 deletions mlab-oti/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,11 @@ provider "google" {
region = "us-central1"
zone = "us-central1-a"
}

provider "google" {
alias = "foundations"
project = "mlab-oti"
region = "us-central1"
zone = "us-central1-a"
}

8 changes: 8 additions & 0 deletions mlab-sandbox/foundations.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "foundations" {
source = "../modules/foundations"

providers = {
google = google.foundations
}
}

7 changes: 7 additions & 0 deletions mlab-sandbox/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,10 @@ provider "google" {
region = "us-central1"
zone = "us-central1-a"
}

provider "google" {
alias = "foundations"
project = "mlab-sandbox"
region = "us-central1"
zone = "us-central1-a"
}
8 changes: 8 additions & 0 deletions mlab-staging/foundations.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module "foundations" {
source = "../modules/foundations"

providers = {
google = google.foundations
}
}

7 changes: 7 additions & 0 deletions mlab-staging/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ provider "google" {
zone = "us-central1-a"
}

provider "google" {
alias = "foundations"
project = "mlab-staging"
region = "us-central1"
zone = "us-central1-a"
}

33 changes: 33 additions & 0 deletions modules/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Submodules

This directory contains Terraform sub- or child-modules that can be included as
necessary in any of the project root modules. This allows us the flexibility of
including, or not, any module in any project, as needed.

A modules in this directory should be named after a logically grouped set of
infrastruture that it implement.

## Module list

### data-pipeline

data-pipeline implements infrastructure associated with the ETL pipeline.

### foundations

foundations implements instrastructure that doesn't neatly fit into any other
logical grouping of resources, or that may be used by more than one logical
resource group. For example, defining the IAM bindings for the default Cloud
Build service account, which may perform builds related to any or all logical
resource groups, or which may perform builds not relevant to any particular
resource group.

### platform-cluster

platform-cluster implements infrastructure associated with M-Lab's primary
platform kubernetes cluster (i.e., where all experiments run).

### visualizations

visualizations implements infrastructure related to visualizations of the M-Lab
data. These visualizations may or may not be public resources.
13 changes: 13 additions & 0 deletions modules/foundations/artifactregistry.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "google_artifact_registry_repository" "build_images" {
location = "us-central1"
repository_id = "build-images"
description = "Cloud Build container images"
format = "DOCKER"
}

resource "google_artifact_registry_repository_iam_member" "member" {
location = google_artifact_registry_repository.build_images.location
repository = google_artifact_registry_repository.build_images.name
role = "roles/artifactregistry.reader"
member = "allUsers"
}
8 changes: 8 additions & 0 deletions modules/foundations/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
}
}
}

1 change: 1 addition & 0 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ terraform {
version = "5.12.0"
configuration_aliases = [
google.data-pipeline,
google.foundations,
google.platform-cluster,
google.visualizations
]
Expand Down

0 comments on commit a3690e5

Please sign in to comment.