Skip to content

Coolomina/terraform-gitlab-mr-to-slack

Repository files navigation

GitLab merge request notification to Slack Terraform module

This module creates an API Gateway and an AWS Lambda function that send notifications to Slack for each merge request event you want to be subscribed to.

GitLab will send a webhook notification to your lambda when you open/update a merge request. The lambda will then send a message to Slack channels depending on the labels applied to the merge request and the configuration specified when invoking the Terraform module.

Requirements

Supported Features

  • AWS Lambda runtime Ruby 2.7
  • Create API Gateway
  • Create AWS Lambda
  • Configuration as Terraform code
  • Potentially all features from lambda and apigatewayv2 community modules

Usage

module "gitlab_mr_to_slack" {
  source  = "https://github.com/Coolomina/terraform-gitlab-mr-to-slack"

  slack_webhook_url = "https://hooks.slack.com/services/XXX/YYY/ZZZ"
  labels_to_notify  = {
	  "SRE": "#sre-pr-reviews"
	  "DEV": "#dev-reviews"
	  "QA": "#qa-reviews"
  }
}

GitLab configuration

After applying, you can run $ terraform output -raw webhook_endpoint and paste that endpoint in your GitLab webhook integration URL. You'll want to specify only Merge request events, as you'll be billed for each invocation of the lambda.

Requirements

Name Version
terraform >= 0.13.1
local >= 2.1

Providers

Name Version
local 2.1.0

Modules

Name Source Version
api_gateway terraform-aws-modules/apigateway-v2/aws v1.5.1
lambda_function terraform-aws-modules/lambda/aws v2.34.0

Resources

Name Type
local_file.config resource

Inputs

Name Description Type Default Required
api_gateway_cors_allow_headers API Gateway allowed headers list(string)
[
"content-type",
"x-amz-date",
"authorization",
"x-api-key",
"x-amz-security-token",
"x-amz-user-agent"
]
no
api_gateway_cors_allow_methods API Gateway allowed headers list(string)
[
"POST"
]
no
api_gateway_cors_allow_origins List of origins to allow traffic from. list(string)
[
"*"
]
no
api_gateway_description API Gateway description string "API that derives POST notifications from Gitlab to the associated lambda" no
custom_uri_path Custom path for the API Gateway endpoint string "/" no
gitlab_subscribe_events Gitlab Merge Request events to subscribe to string "open,update" no
labels_to_notify A map of labels and corresponding slack channels to notify map(string) n/a yes
lambda_description Description of the lambda functionality string "This lambda will receive http events from API gateway and will ship them to a Slack channel." no
name Name of the stack string "gitlab-to-slack" no
slack_username Slack username to send notifications as string "Gitlab MR webhook" no
slack_webhook_url Integration URL of Slack Webhook. Eg. https://hooks.slack.com/services/XX/YYYYY/ZZZZZZ string n/a yes

Outputs

Name Description
webhook_endpoint The public full URL of your lambda

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published