Skip to content

Latest commit

 

History

History

aws-ts-pulumi-webhooks

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Deploy this example with Pulumi Deploy this example with Pulumi

Pulumi Webhook Handler

This example creates a Pulumi cloud.HttpEndpoint that will receive webhook events delivered by Pulumi Cloud. It then echos the event to Slack.

Prerequisites

  1. Install Pulumi
  2. Configure AWS Credentials

Steps

After cloning this repo, run these commands from the working directory:

  1. Install prerequisites:

    npm install
  2. Create a new Pulumi stack, which is an isolated deployment target for this example:

    pulumi stack init
  3. Create a Slack App:

    • Give your app the incoming-webhook scope.

    • Add your Slack app to the Slack channel in which you want to post webhook events.

  4. Set the region for this program:

    pulumi config set aws:region <your-region>
  5. Set the Slack webhook for your app. You can find yours by going to Features -> Incoming Webhooks from your Slack app's API page.

    pulumi config set slackWebhook --secret <webhook-url>
  6. Set the Slack channel for your app. This should be the same channel in which you added your Slack app. For example, #pulumi-events.

    pulumi config set slackChannel <your-channel>
  7. (Optional) Set the shared secret for your app. Webhook deliveries can optionally be signed with a shared secret token. The shared secret is given to Pulumi, and will be used to verify the contents of the message. You can find yours by going to Settings -> Basic Information -> Signing Secret from your Slack app's API page.

    pulumi config set sharedSecret --secret <your-secret>
  8. Execute the Pulumi program:

    pulumi up
  9. Retrieve our new URL:

    pulumi stack output url
  10. Create a Pulumi webhook. Use the output from the previous step as the Payload URL.

  11. Ping our webhook by clicking Ping under Deliveries from your webhook's page. You should see the message Just a friendly ping from Pulumi in your Slack channel.

  12. From there, feel free to experiment. Simply making edits and running pulumi up will update your program.

  13. Afterwards, destroy your stack and remove it:

    pulumi destroy --yes
    pulumi stack rm --yes

Troubleshooting

Message Delivery

If you aren't seeing webhook deliveries in Slack, there are several places to look for more information.

  • Pulumi Cloud: If you go to the webhook's page within the Pulumi console, you can navigate to recent webhook deliveries. If Pulumi Cloud has any trouble contacting your webhook handler, you will see the error there.
  • The Pulumi stack's logs: If the webhooks are being delivered, but aren't showing up in Slack for some reason, you can view the webhook handler's runtime logs by running the pulumi logs command.