Skip to content

gold3nfish/tf-discord-webhook-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Terraform -> Discord Webhook Proxy

Go Report Card Build Docker Hub Publish Docker Hub Image

Have you ever wanted to use the webhook notification system on Terraform Cloud to notify a Discord channel of your infrastructure state changes, only to realize that they can't natively talk to each other? Well not anymore, because here's the tool you've been searching for!

Terraform webhook comes in, Discord webhook goes out, profit.

By default, an embedded rich message will be sent to Discord but this can be disabled in the config file.

Sample embed message:

Rich Message

The color of the message (on the left side) will be either green (success), red (error), blue (plan needs confirmation), or yellow (other).

Usage

  1. Download: go get github.com/captainGeech42/tf-discord-webhook-proxy
  2. Copy the config.ex.json file to your current directory as config.json
  3. Update the WebhookURL field with a Discord webhook URL (Discord docs on webhooks)
  4. Run it: tf-discord-webhook-proxy

The proxy will be available at http://host:8080/webhook. Add that URL to a new Webhook Notification in the Notifications settings in your Terraform Cloud workspace.

Docker Image

This tool is also available via a Docker image on Docker Hub (captaingeech/tf-discord-webhook-proxy). When running via the Docker image, you can either use this image as a base image to COPY your config.json into /app, or set the following environment variables instead:

  • TF_PROXY_ENV=YES (without this, a config.json will be looked for)
  • TF_PROXY_WEBHOOK_URL="https://discordapp.com/api/webhooks/xxxxxxxx/yyyyyyyyyyyyy"
  • TF_PROXY_RICH_MESSAGES=YES (optional, disable rich messages by setting to NO)

The Docker image will always have the proxy running on port 8080 in the container, you can choose to forward this outside of the container to whatever port you need.

Example execution of container:

docker run --rm -it -p8080:8080 \
           -e TF_PROXY_ENV=YES \
           -e TF_PROXY_WEBHOOK_URL="https://discordapp.com/api/webhooks/xxxxxxxx/yyyyyyyyyyyyy" \
           captaingeech/tf-discord-webhook-proxy:latest

About

Terraform -> Discord Webhook Proxy

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 92.5%
  • Dockerfile 7.5%