Skip to content

Commit

Permalink
feat(appinfra): configurable envs
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody committed Jun 14, 2024
1 parent 77263bf commit fc6d8a2
Show file tree
Hide file tree
Showing 21 changed files with 103 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
module "app" {
source = "../../../../../modules/cicd-pipeline"

project_id = var.project_id
region = var.region
cluster_membership_id_dev = var.cluster_membership_id_dev
cluster_membership_ids_nonprod = var.cluster_membership_ids_nonprod
cluster_membership_ids_prod = var.cluster_membership_ids_prod
project_id = var.project_id
region = var.region
env_cluster_membership_ids = var.env_cluster_membership_ids

service = local.service_name
repo_name = local.repo_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ variable "region" {
type = string
}

variable "cluster_membership_id_dev" {
description = "Cluster fleet membership ID in development environment"
type = string
}

variable "cluster_membership_ids_nonprod" {
description = "Cluster fleet membership IDs in nonprod environment"
type = list(string)
}

variable "cluster_membership_ids_prod" {
description = "Cluster fleet membership IDs in prod environment"
type = list(string)
variable "env_cluster_membership_ids" {
description = "Cluster Membership IDs"
type = map(object({
cluster_membership_ids = list(string)
}))
}

variable "buckets_force_destroy" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
module "app" {
source = "../../../../../modules/cicd-pipeline"

project_id = var.project_id
region = var.region
cluster_membership_id_dev = var.cluster_membership_id_dev
cluster_membership_ids_nonprod = var.cluster_membership_ids_nonprod
cluster_membership_ids_prod = var.cluster_membership_ids_prod
project_id = var.project_id
region = var.region
env_cluster_membership_ids = var.env_cluster_membership_ids

service = local.service_name
repo_name = local.repo_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ variable "region" {
type = string
}

variable "cluster_membership_id_dev" {
description = "Cluster fleet membership ID in development environment"
type = string
}

variable "cluster_membership_ids_nonprod" {
description = "Cluster fleet membership IDs in nonprod environment"
type = list(string)
}

variable "cluster_membership_ids_prod" {
description = "Cluster fleet membership IDs in prod environment"
type = list(string)
variable "env_cluster_membership_ids" {
description = "Cluster Membership IDs"
type = map(object({
cluster_membership_ids = list(string)
}))
}

variable "buckets_force_destroy" {
Expand Down
8 changes: 3 additions & 5 deletions 5-appinfra/apps/cymbal-bank/frontend/envs/shared/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
module "app" {
source = "../../../../../modules/cicd-pipeline"

project_id = var.project_id
region = var.region
cluster_membership_id_dev = var.cluster_membership_id_dev
cluster_membership_ids_nonprod = var.cluster_membership_ids_nonprod
cluster_membership_ids_prod = var.cluster_membership_ids_prod
project_id = var.project_id
region = var.region
env_cluster_membership_ids = var.env_cluster_membership_ids

service = local.service_name
repo_name = local.repo_name
Expand Down
18 changes: 5 additions & 13 deletions 5-appinfra/apps/cymbal-bank/frontend/envs/shared/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ variable "region" {
type = string
}

variable "cluster_membership_id_dev" {
description = "Cluster fleet membership ID in development environment"
type = string
}

variable "cluster_membership_ids_nonprod" {
description = "Cluster fleet membership IDs in nonprod environment"
type = list(string)
}

variable "cluster_membership_ids_prod" {
description = "Cluster fleet membership IDs in prod environment"
type = list(string)
variable "env_cluster_membership_ids" {
description = "Cluster Membership IDs"
type = map(object({
cluster_membership_ids = list(string)
}))
}

variable "buckets_force_destroy" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
module "app" {
source = "../../../../../modules/cicd-pipeline"

project_id = var.project_id
region = var.region
cluster_membership_id_dev = var.cluster_membership_id_dev
cluster_membership_ids_nonprod = var.cluster_membership_ids_nonprod
cluster_membership_ids_prod = var.cluster_membership_ids_prod
project_id = var.project_id
region = var.region
env_cluster_membership_ids = var.env_cluster_membership_ids

service = local.service_name
repo_name = local.repo_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ variable "region" {
type = string
}

variable "cluster_membership_id_dev" {
description = "Cluster fleet membership ID in development environment"
type = string
}

variable "cluster_membership_ids_nonprod" {
description = "Cluster fleet membership IDs in nonprod environment"
type = list(string)
}

variable "cluster_membership_ids_prod" {
description = "Cluster fleet membership IDs in prod environment"
type = list(string)
variable "env_cluster_membership_ids" {
description = "Cluster Membership IDs"
type = map(object({
cluster_membership_ids = list(string)
}))
}

variable "buckets_force_destroy" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
module "app" {
source = "../../../../../modules/cicd-pipeline"

project_id = var.project_id
region = var.region
cluster_membership_id_dev = var.cluster_membership_id_dev
cluster_membership_ids_nonprod = var.cluster_membership_ids_nonprod
cluster_membership_ids_prod = var.cluster_membership_ids_prod
project_id = var.project_id
region = var.region
env_cluster_membership_ids = var.env_cluster_membership_ids

service = local.service_name
repo_name = local.repo_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ variable "region" {
type = string
}

variable "cluster_membership_id_dev" {
description = "Cluster fleet membership ID in development environment"
type = string
}

variable "cluster_membership_ids_nonprod" {
description = "Cluster fleet membership IDs in nonprod environment"
type = list(string)
}

variable "cluster_membership_ids_prod" {
description = "Cluster fleet membership IDs in prod environment"
type = list(string)
variable "env_cluster_membership_ids" {
description = "Cluster Membership IDs"
type = map(object({
cluster_membership_ids = list(string)
}))
}

variable "buckets_force_destroy" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ locals {
module "app" {
source = "../../../../../modules/cicd-pipeline"

project_id = var.project_id
region = var.region
cluster_membership_id_dev = var.cluster_membership_id_dev
cluster_membership_ids_nonprod = var.cluster_membership_ids_nonprod
cluster_membership_ids_prod = var.cluster_membership_ids_prod
project_id = var.project_id
region = var.region
env_cluster_membership_ids = var.env_cluster_membership_ids

service = local.service_name
repo_name = local.repo_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ variable "region" {
type = string
}

variable "cluster_membership_id_dev" {
description = "Cluster fleet membership ID in development environment"
type = string
}

variable "cluster_membership_ids_nonprod" {
description = "Cluster fleet membership IDs in nonprod environment"
type = list(string)
}

variable "cluster_membership_ids_prod" {
description = "Cluster fleet membership IDs in prod environment"
type = list(string)
variable "env_cluster_membership_ids" {
description = "Cluster Membership IDs"
type = map(object({
cluster_membership_ids = list(string)
}))
}

variable "buckets_force_destroy" {
Expand Down
4 changes: 1 addition & 3 deletions 5-appinfra/modules/cicd-pipeline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| buckets\_force\_destroy | When deleting the bucket for storing CICD artifacts, this boolean option will delete all contained objects. If false, Terraform will fail to delete buckets which contain objects. | `bool` | `false` | no |
| cluster\_membership\_id\_dev | Fleet membership ID for the cluster in development environment | `string` | n/a | yes |
| cluster\_membership\_ids\_nonprod | Fleet membership IDs for the cluster in non-production environment | `list(string)` | n/a | yes |
| cluster\_membership\_ids\_prod | Fleet membership IDs for the cluster in production environment | `list(string)` | n/a | yes |
| env\_cluster\_membership\_ids | Env Cluster Membership IDs | <pre>map(object({<br> cluster_membership_ids = list(string)<br> }))</pre> | n/a | yes |
| project\_id | CI/CD project ID | `string` | n/a | yes |
| region | CI/CD Region (e.g. us-central1) | `string` | n/a | yes |
| repo\_branch | Branch to sync ACM configs from & trigger CICD if pushed to. | `string` | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion 5-appinfra/modules/cicd-pipeline/artifact-registry.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ resource "google_artifact_registry_repository" "container_registry" {
repository_id = local.service_name
location = var.region
format = "docker"
description = "Bank of Anthos docker repository"
description = "${local.service_name} docker repository"
project = var.project_id

depends_on = [
Expand Down
4 changes: 2 additions & 2 deletions 5-appinfra/modules/cicd-pipeline/cloud-deploy.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ resource "google_clouddeploy_delivery_pipeline" "delivery-pipeline" {
name = local.service_name
serial_pipeline {
dynamic "stages" {
for_each = { for idx, target in local.targets : idx => target }
for_each = google_clouddeploy_target.clouddeploy_targets
content {
# TODO: use "production" profile once it works.
# TODO: use "production" profile once validated.
profiles = [stages.value.name == "${local.service_name}-dev" ? "development" : (startswith(stages.value.name, "${local.service_name}-nonprod") ? "staging" : "production")]
target_id = stages.value.name
}
Expand Down
1 change: 0 additions & 1 deletion 5-appinfra/modules/cicd-pipeline/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ locals {
service_name = reverse(split("-", var.service))[0]
team_name = split("-", var.service)[0]
service_clean = replace(var.service, "/", "-")
targets = [google_clouddeploy_target.development, google_clouddeploy_target.non_prod[0], google_clouddeploy_target.non_prod[1], google_clouddeploy_target.prod[0], google_clouddeploy_target.prod[1]]
container_registry = google_artifact_registry_repository.container_registry
}
Loading

0 comments on commit fc6d8a2

Please sign in to comment.