A Terraform module to enable Slack notifications for Cloud Build events.
Note - This will add the following resources to your project:
- Google Cloud Storage Bucket for storing the notifier configuration
- Google Pub/Sub for events emitted from Cloud Build
- Google Cloud Run for processing the events emitted from Cloud Build
This module is based on the instructions found in GCP's Configuring Slack notifications guide.
You will need a Slack app incoming webhook url stored in a Google Secret Manager secret for this to work.
- Create a Slack app for your desired Slack workspace.
- Activate incoming webhooks to post messages from Cloud Build to Slack.
- Create a new secret in Google Secret Manager and store the webhook url in it.
Pre-commit hooks have been configured for this repo.
The enabled hooks check for a variety of common problems in Terraform code, and will run any time you commit to your branch.
Pre-commit (and dependencies) can be installed by following the instructions found here:
To enable the hooks locally, run the following from the root of this repo:
pre-commit install
To uninstall the hooks, run the following from the root of this repo:
pre-commit uninstall
To skip running the hooks when you commit:
git commit -n
aka git commit --no-verify
Currently enabled plugins:
- pre-commit-terraform
terraform_fmt
: Rewrites all Terraform configuration files to a canonical formatterraform_docs
: Inserts input and output documentation intoREADME.md
terraform_validate
: Validates all Terraform configuration files
- pre-commit-hooks
end-of-file-fixer
: Makes sure files end in a newline and only a newlinetrailing-whitespace
: Trims trailing whitespacecheck-merge-conflict
: Check for files that contain merge conflict strings
Name | Version |
---|---|
terraform | >= 0.13 |
>= 3.20 | |
google-beta | >= 3.30 |
random | >= 2.1 |
Name | Version |
---|---|
>= 3.20 | |
google-beta | >= 3.30 |
random | >= 2.1 |
No modules.
Name | Description | Type | Default |
---|---|---|---|
cloud_build_event_filter | The CEL filter to apply to incoming Cloud Build events. | string |
"build.substitutions['BRANCH_NAME'] == 'main' && build.status in [Build.Status.SUCCESS, Build.Status.FAILURE, Build.Status.TIMEOUT]" |
cloud_build_notifier_image | The image to use for the notifier. | string |
"us-east1-docker.pkg.dev/gcb-release/cloud-build-notifiers/slack:latest" |
disable_services_on_destroy | If true, the service APIs used will be disabled on destroy. | bool |
false |
name | The name to use on all resources created. | string |
n/a |
override_slack_template_json | Custom template to use for the Slack notifications, which overrides the default. | string |
"" |
project_id | Project ID of the project in which Cloud Build is running. | string |
n/a |
region | The region in which to deploy the notifier service. | string |
"us-central1" |
slack_webhook_url_secret_id | The ID of an existing Google Secret Manager secret, containing a Slack webhook URL. This is usually the id from the output of a google_secret_manager_secret resource. |
string |
n/a |
slack_webhook_url_secret_project | The project ID containing the slack_webhook_url_secret_id. | string |
n/a |
No outputs.