Skip to content

This is a Golang application that listens for Terraform Cloud webhooks and sends formatted messages to a Discord webhook based on the webhook payload.

License

Notifications You must be signed in to change notification settings

smark91/terraform-cloud-discord-webhook-proxy

Repository files navigation

Terraform Cloud Discord Webhook Proxy

Made using ChatGPT conversation (included this README.md) ❤️

This is a Golang application that listens for Terraform Cloud webhooks and sends formatted messages to a Discord webhook based on the webhook payload.

Prerequisites

Setup

  1. Create a Discord webhook for your server or channel. Follow the instructions in this guide to create a webhook URL.

  2. Set the TF_DISCORD_PROXY_WEBHOOK_URL environment variable to the Discord webhook URL:

    export TF_DISCORD_PROXY_WEBHOOK_URL=<your-discord-webhook-url>
  3. (Optional) Set the TF_DISCORD_PROXY_PORT environment variable to the desired port number (default is 8080):

    export TF_DISCORD_PROXY_PORT=<your-port-number>
  4. (Optional) Set the TF_DISCORD_PROXY_AUTH_TOKEN environment variable to the Terraform Cloud webhook auth token:

    export TF_DISCORD_PROXY_AUTH_TOKEN=<your-terraform-cloud-webhook-auth-token>
  5. Build and run the Golang application:

    go run main.go

    or

    docker run -p $TF_DISCORD_PROXY_PORT:8080 -e TF_DISCORD_PROXY_WEBHOOK_URL=$TF_DISCORD_PROXY_WEBHOOK_URL -e TF_DISCORD_PROXY_AUTH_TOKEN=$TF_DISCORD_PROXY_AUTH_TOKEN smark91/terraform-cloud-discord-webhook:<image-version>
  6. In your Terraform Cloud workspace, create a notification configuration with the following settings:

  • Name: Discord Webhook
  • Trigger: All events
  • URL: <your-server-url>/webhook (replace <your-server-url> with the URL of your server where the Docker container is running)
  • Token: <your-terraform-cloud-webhook-auth-token> (optional, replace <your-terraform-cloud-webhook-auth-token> with a secret webhook auth token)
  1. Create a new run in your Terraform Cloud workspace to trigger the webhook.

Using Docker Compose

If you prefer to use Docker Compose to run the Terraform Cloud Discord webhook proxy, follow these steps:

  1. Create a Discord webhook for your server or channel. Follow the instructions in this guide to create a webhook URL.

  2. Create a file named docker-compose.yml with the following contents:

    version: '3'
    services:
      terraform-cloud-discord-webhook-proxy:
        image: smark91/terraform-cloud-discord-webhook-proxy:<image-version>
        ports:
          - "8080:8080"
        environment:
          - TF_DISCORD_PROXY_WEBHOOK_URL=<your-discord-webhook-url>
          # - TF_DISCORD_PROXY_PORT=8080
          # - TF_DISCORD_PROXY_AUTH_TOKEN=<your-terraform-cloud-webhook-auth-token>

    Replace <your-discord-webhook-url> with the Discord webhook URL, and <your-terraform-cloud-webhook-auth-token> with the Terraform Cloud webhook auth token (if you specified one).

  3. Run the following command to start the Docker Compose stack:

    docker-compose up -d

About

This is a Golang application that listens for Terraform Cloud webhooks and sends formatted messages to a Discord webhook based on the webhook payload.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •