Skip to main content

AWS Lambda for Slack notification

Deploy a Slack webhook Lambda function.

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set aws-ts-lambda-slack
cd pulumi-examples/aws-ts-lambda-slack

A Pulumi example that:

  • Creates an AWS Lambda function to post a message on Slack via a Webhook URL.
  • Adds an AWS API Gateway so the Lambda can be invoked externally, e.g, via GitHub Webhooks.
  • Uses a Pulumi ESC Environment to dynamically retrieve AWS OIDC Credentials and the Slack URL from AWS Secrets Manager.

Last update: September 2024

Prerequisites#

  1. Install Pulumi
  2. Configure AWS credentials
  3. Install Node.js
  4. A Pulumi Cloud account
  5. AWS OIDC configured in a Pulumi ESC Environment
  6. AWS Secrets Manager with a Slack Webhook URL secret
  7. A properly configured Slack Webhook URL

Deploying the example#

This Pulumi example is written as a template. It is meant to be copied via pulumi new.

  1. Log in to your Pulumi Cloud if you haven’t already:

    Terminal window
    pulumi login
  2. Create a new directory and change into it:

    Terminal window
    mkdir my-slack-demo
    cd my-slack-demo
  3. Start your Pulumi project from this example:

    Terminal window
    pulumi new https://github.com/pulumi/examples/aws-ts-lambda-slack
  4. Add your Pulumi ESC Environment and deploy:

    Terminal window
    pulumi config env add YOUR_ESC_ENV --yes --non-interactive
    pulumi up

    Select ‘yes’ to confirm the expected changes.

Cleaning up#

To clean up your infrastructure, run:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.