Skip to main content

Webhook 🆕

Webhooks in StackGuardian, offer a dynamic way to integrate external services with your cloud infrastructure workflows. These hooks trigger HTTP POST requests in response to specified events in your workflows or stacks, enabling real-time automation and communication with other systems.

Step-by-Step Guide to Create a Webhook​

In this guide, we configure a webhook to alert the team upon the success, failure, or on Drift Detection of a Terraform workflow. This workflow is responsible for deploying and managing an AWS website using the 'aws-s3-demo-website' Infrastructure as Code template.

To begin, click "Create Workflow" and select the terraform type with Use Wizard (Preview):

1. Source and Parameters​

  1. Choose "Subscribed Templates" for ready-to-use blueprint templates from your library.
  2. Under Source Type, choose Subscribed Template and search for aws-s3-demo-website
  3. In "Template Parameters" pick the latest revision, click Next.

2. Runtime Environment​

  1. In "Deployment Environment", select a connector that matches your platform or environment, set environment variables if needed, and click Next.
  2. Specify the "Runner type" under "Execution Environment" for execution flexibility and organizational visibility.
  3. Opt-in for Automated Drift Check, Terraform Plan Approval, and SG Managed Backend to streamline workflow execution, state and lifecycle management for the workflows.
  4. Under Advanced Options > Resources and Events > Webhook, set up the webhooks:
  • For Errors: Captures and notifies when workflow errors occur.

    • Webhook Name: Error Webhook.
    • Webhook URL: Enter the Generic JSON webhook URL.
    • Webhook Secret: Enter the secret (optional).
  • For Success: Sends notifications upon successful completion of the workflow.

    • Webhook Name: Success Webhook.
    • Use the same Generic JSON webhook URL and secret as for errors.
  • On Drift Detection: Alerts when configuration drift is detected in the infrastructure.

    • Webhook Name: Drift Detection Webhook.
    • Use the same Generic JSON webhook URL and secret as for other events.
  • Click Add for each event to finalize and click Next.

3. Workflow Metadata​

  1. Workflow Name: Suggest a name, like wehook-workflow.
  2. Description and Tags: Provide an optional description and tags, click "Next" to proceed.

4. Review and Launch​

  • Review the settings and click Launch to create your workflow.

Fig: Setting up a 'Static S3 website' Terraform workflow with webhook

With these steps, StackGuardian will emit a JSON payload the workflow's outcome, which can integrated with other different services.