Skip to content

Commit

Permalink
feat(TPG>=6.12)!: support image for slo_generator (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
apeabody authored Jan 29, 2025
1 parent 4ca4274 commit ec6f9fd
Show file tree
Hide file tree
Showing 36 changed files with 172 additions and 247 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Make will use bash instead of sh
SHELL := /usr/bin/env bash

DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.0
DOCKER_TAG_VERSION_DEVELOPER_TOOLS := 1.23
DOCKER_IMAGE_DEVELOPER_TOOLS := cft/developer-tools
REGISTRY_URL := gcr.io/cloud-foundation-cicd

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ SLO Configurations are pushed to Google Cloud Storage, and schedules are maintai
![Architecture](./arch.png)

### Compatibility
This module is meant for use with Terraform 0.13+ and tested using Terraform 1.0+. If you find incompatibilities using Terraform >=0.13, please open an issue.
If you haven't
This module is meant for use with Terraform v1.3+ and tested using Terraform 1.10+. If you haven't
[upgraded](https://www.terraform.io/upgrade-guides/0-13.html) and need a Terraform
0.12.x-compatible version of this module, the last released version
intended for Terraform 0.12.x is [v1.0.2](https://registry.terraform.io/modules/terraform-google-modules/-slo/google/v1.0.2).
Expand Down
4 changes: 2 additions & 2 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
args: ['module-swapper']
- id: prepare
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment']
args: ['/bin/bash', '-c', 'source /usr/local/bin/task_helper_functions.sh && prepare_environment ; sleep 120']
env:
- 'TF_VAR_org_id=$_ORG_ID'
- 'TF_VAR_folder_id=$_FOLDER_ID'
Expand All @@ -41,4 +41,4 @@ tags:
- 'integration'
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.0'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.23'
24 changes: 0 additions & 24 deletions build/lint.cloudbuild.yaml

This file was deleted.

27 changes: 27 additions & 0 deletions docs/upgrading_to_slo_v4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Upgrading to terraform-google-slo v4.0

The v4.0 release of the `slo` module is a backward incompatible release.

### Google Cloud Platform Provider upgrade
The `slo` module now requires version v6.12+ of the Google Cloud Platform Providers. See the [Terraform Google Provider 6.0.0 Upgrade Guide](https://registry.terraform.io/providers/hashicorp/google/latest/docs/guides/version_6_upgrade) for more details.

### Terraform upgrade
The `slo` module now requires version v1.3+ of Terraform.

### slo-generator image

The use of a custom `slo-generator` image now requires the `slo_generator_remote` and `slo_generator_image` variables, rather than `gcr_project_id`.

```diff
module "slo-generator" {
source = "terraform-google-modules/slo/google//modules/slo-generator"
- version = "~> 3.0"
+ version = "~> 4.0"

- gcr_project_id = "slo-generator-ci-a2b4"
- slo_generator_version = "latest"
+ slo_generator_remote = "ghcr.io"
+ slo_generator_image = "google/slo-generator"
+ slo_generator_version = "master"
}
```
2 changes: 1 addition & 1 deletion examples/native/simple_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To run this example, you'll need:

## Outputs

No output.
No outputs.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Expand Down
4 changes: 0 additions & 4 deletions examples/slo-generator/simple_example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ To run this example, you'll need:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| gcr\_project\_id | Google Container registry project where image is hosted | `string` | `"slo-generator-ci-a2b4"` | no |
| labels | Project labels | `map` | `{}` | no |
| project\_id | Project id | `any` | n/a | yes |
| region | Region | `string` | `"us-east1"` | no |
| schedule | Cron-like Cloud Scheduler schedule | `string` | `"* * * * */1"` | no |
| slo\_generator\_version | SLO generator version | `string` | `"latest"` | no |

## Outputs

Expand Down
10 changes: 4 additions & 6 deletions examples/slo-generator/simple_example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ module "slo-generator" {
source = "terraform-google-modules/slo/google//modules/slo-generator"
version = "~> 3.0"

project_id = var.project_id
region = var.region
config = local.config
slo_configs = local.slo_configs
slo_generator_version = var.slo_generator_version
gcr_project_id = var.gcr_project_id
project_id = var.project_id
region = var.region
config = local.config
slo_configs = local.slo_configs
secrets = {
PROJECT_ID = var.project_id
}
Expand Down
20 changes: 0 additions & 20 deletions examples/slo-generator/simple_example/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,7 @@ variable "project_id" {
description = "Project id"
}

variable "schedule" {
description = "Cron-like Cloud Scheduler schedule"
default = "* * * * */1"
}

variable "region" {
description = "Region"
default = "us-east1"
}

variable "gcr_project_id" {
description = "Google Container registry project where image is hosted"
default = "slo-generator-ci-a2b4"
}

variable "slo_generator_version" {
description = "SLO generator version"
default = "latest"
}

variable "labels" {
description = "Project labels"
default = {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ To run this example, you'll need:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| gcr\_project\_id | Google Container registry project where image is hosted | `string` | `"slo-generator-ci-a2b4"` | no |
| labels | Project labels | `map` | `{}` | no |
| project\_id | Project id | `any` | n/a | yes |
| region | Region | `string` | `"us-east1"` | no |
| schedule | Cron-like Cloud Scheduler schedule | `string` | `"* * * * */1"` | no |
| slo\_generator\_version | SLO generator version | `string` | `"latest"` | no |

## Outputs

Expand Down
24 changes: 10 additions & 14 deletions examples/slo-generator/sre_export_cloudevent_eventarc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ module "slo-generator" {
source = "terraform-google-modules/slo/google//modules/slo-generator"
version = "~> 3.0"

project_id = var.project_id
region = var.region
config = local.config
slo_configs = local.slo_configs
slo_generator_version = var.slo_generator_version
gcr_project_id = var.gcr_project_id
project_id = var.project_id
region = var.region
config = local.config
slo_configs = local.slo_configs
secrets = {
PROJECT_ID = var.project_id
PUBSUB_TOPIC_NAME = google_pubsub_topic.topic.name
Expand All @@ -43,14 +41,12 @@ module "slo-generator-export" {
source = "terraform-google-modules/slo/google//modules/slo-generator"
version = "~> 3.0"

service_name = "slo-generator-export"
target = "run_export"
signature_type = "cloudevent"
project_id = var.project_id
region = var.region
config = local.config_export
slo_generator_version = var.slo_generator_version
gcr_project_id = var.gcr_project_id
service_name = "slo-generator-export"
target = "run_export"
signature_type = "cloudevent"
project_id = var.project_id
region = var.region
config = local.config_export
secrets = {
SRE_PROJECT_ID = var.project_id
}
Expand Down
20 changes: 0 additions & 20 deletions examples/slo-generator/sre_export_cloudevent_eventarc/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,7 @@ variable "project_id" {
description = "Project id"
}

variable "schedule" {
description = "Cron-like Cloud Scheduler schedule"
default = "* * * * */1"
}

variable "region" {
description = "Region"
default = "us-east1"
}

variable "gcr_project_id" {
description = "Google Container registry project where image is hosted"
default = "slo-generator-ci-a2b4"
}

variable "slo_generator_version" {
description = "SLO generator version"
default = "latest"
}

variable "labels" {
description = "Project labels"
default = {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@ To run this example, you'll need:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| gcr\_project\_id | Google Container Registry project to fetch slo-generator image from | `string` | `"slo-generator-ci-a2b4"` | no |
| project\_id | SRE Project id | `any` | n/a | yes |
| region | Region | `string` | `"us-east1"` | no |
| slo\_generator\_version | Version of slo-generator image | `string` | `"latest"` | no |
| team1\_project\_id | Team 1 project id | `any` | n/a | yes |

## Outputs
Expand Down
4 changes: 0 additions & 4 deletions examples/slo-generator/sre_export_cloudevent_exporter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ module "slo-generator" {
region = var.region
config = local.team1_config
slo_configs = local.team1_slo_configs
gcr_project_id = var.gcr_project_id
slo_generator_version = var.slo_generator_version
service_account_email = google_service_account.team1_service_account.email
secrets = {
TEAM1_PROJECT_ID = var.team1_project_id
Expand All @@ -64,8 +62,6 @@ module "slo-generator-export" {
project_id = var.project_id
region = var.region
config = local.sre_config
gcr_project_id = var.gcr_project_id
slo_generator_version = var.slo_generator_version
service_account_email = local.service_account_email
secrets = {
SRE_PROJECT_ID = var.project_id
Expand Down
10 changes: 0 additions & 10 deletions examples/slo-generator/sre_export_cloudevent_exporter/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,3 @@ variable "project_id" {
variable "team1_project_id" {
description = "Team 1 project id"
}

variable "gcr_project_id" {
description = "Google Container Registry project to fetch slo-generator image from"
default = "slo-generator-ci-a2b4"
}

variable "slo_generator_version" {
description = "Version of slo-generator image"
default = "latest"
}
4 changes: 0 additions & 4 deletions examples/slo-generator/sre_service_advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,8 @@ To run this example, you'll need:
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| bigquery\_dataset\_name | BigQuery dataset to hold SLO reports | `string` | `"slo"` | no |
| gcr\_project\_id | Google Container registry project where image is hosted | `string` | `"slo-generator-ci-a2b4"` | no |
| project\_id | SRE Project id | `any` | n/a | yes |
| pubsub\_topic\_name | PubSub topic name | `string` | `"slo-export"` | no |
| region | Region | `string` | `"us-east1"` | no |
| schedule | Cron-like Cloud Scheduler schedule | `string` | `"* * * * */1"` | no |
| slo\_generator\_version | slo-generator image version | `string` | `"latest"` | no |
| team1\_project\_id | Team 1 project id | `any` | n/a | yes |
| team2\_project\_id | Team 2 project id | `any` | n/a | yes |

Expand Down
2 changes: 0 additions & 2 deletions examples/slo-generator/sre_service_advanced/sre.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ module "slo-generator" {
config = local.sre_config
service_account_email = local.service_account_email
slo_configs = local.sre_slo_configs
gcr_project_id = var.gcr_project_id
slo_generator_version = var.slo_generator_version
secrets = {
SRE_PROJECT_ID = var.project_id
SRE_BIGQUERY_DATASET_ID = google_bigquery_dataset.export-dataset.dataset_id
Expand Down
10 changes: 4 additions & 6 deletions examples/slo-generator/sre_service_advanced/teams.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ module "team1-slos" {
source = "terraform-google-modules/slo/google//modules/slo-generator"
version = "~> 3.0"

project_id = var.team1_project_id
region = var.region
config = local.team1_config
slo_configs = local.team1_configs
gcr_project_id = var.gcr_project_id
slo_generator_version = var.slo_generator_version
project_id = var.team1_project_id
region = var.region
config = local.team1_config
slo_configs = local.team1_configs
secrets = {
SRE_PROJECT_ID = var.project_id
SRE_BIGQUERY_DATASET_ID = google_bigquery_dataset.export-dataset.dataset_id
Expand Down
20 changes: 0 additions & 20 deletions examples/slo-generator/sre_service_advanced/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,12 @@ variable "team2_project_id" {
description = "Team 2 project id"
}

variable "gcr_project_id" {
description = "Google Container registry project where image is hosted"
default = "slo-generator-ci-a2b4"
}

variable "schedule" {
description = "Cron-like Cloud Scheduler schedule"
default = "* * * * */1"
}

variable "region" {
description = "Region"
default = "us-east1"
}

variable "pubsub_topic_name" {
description = "PubSub topic name"
default = "slo-export"
}

variable "bigquery_dataset_name" {
description = "BigQuery dataset to hold SLO reports"
default = "slo"
}

variable "slo_generator_version" {
description = "slo-generator image version"
default = "latest"
}
4 changes: 0 additions & 4 deletions examples/slo-generator/sre_shared_schedulers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,8 @@ To run this example, you'll need:

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| gcr\_project\_id | Google Container registry project where image is hosted | `string` | `"slo-generator-ci-a2b4"` | no |
| labels | Project labels | `map` | `{}` | no |
| project\_id | Project id | `any` | n/a | yes |
| region | Region | `string` | `"us-east1"` | no |
| schedule | Cron-like Cloud Scheduler schedule | `string` | `"* * * * */1"` | no |
| slo\_generator\_version | SLO generator version | `string` | `"latest"` | no |

## Outputs

Expand Down
6 changes: 2 additions & 4 deletions examples/slo-generator/sre_shared_schedulers/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2021 Google LLC
* Copyright 2021-2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,7 +32,7 @@ locals {
}

resource "google_cloud_scheduler_job" "scheduler" {
for_each = { for key, conf in local.frequencies : key => conf if conf.names != [] }
for_each = { for key, conf in local.frequencies : key => conf if length(conf.names) != 0 }
project = var.project_id
region = var.region
schedule = each.value.frequency
Expand All @@ -56,8 +56,6 @@ module "slo-generator" {
region = var.region
config = local.config
slo_configs = local.slo_configs
slo_generator_version = var.slo_generator_version
gcr_project_id = var.gcr_project_id
create_cloud_schedulers = false
secrets = {
PROJECT_ID = var.project_id
Expand Down
Loading

0 comments on commit ec6f9fd

Please sign in to comment.