Altostra Docs

    ›Tutorials

    Getting Started

    • Welcome to Altostra
    • Connect your accounts
    • Install the developer tools
    • Log in from the CLI

    Tutorials

    • Create a Static Website
    • Create a Scalable Webhook
    • Create a Simple API Project
    • Try Altostra without connecting cloud accounts
    • CI/CD with Altostra CLI and Github Actions

    How To

      Working with projects

      • Create a new project
      • Deploy a project
      • Manage a project

      Working with environments

      • Manage an environment
      • Configure instances expiration for an environment

      Working with the Editor

      • Grant access to vendor services
      • Use the Parameter Store
      • Use a custom CloudFormation resource
      • Attach a custom policy to a Function
      • Connect a Function to VPC
      • Add filter policy to SNS subscription

      Organization account settings

      • Set General Settings
      • Connect a Git account
      • Connect Cloud Accounts
      • Manage log aggregation accounts

    CLI

    • Altostra CLI
    • Commands

      • templates
      • new
      • init
      • push
      • deploy
      • sls-deploy
      • sync
      • invalidate
      • domains
      • console
      • environments
      • images
      • instances
      • build
      • config
      • import
      • projects
      • tasks
      • activity-log
      • login
      • logout
      • account
      • whoami
      • api-key
      • docs

      Options

      • --debug
      • --verbose
      • Scripting options
    • Configuration files

    Errors And Solutions

    • Autnentication Required

    Technical Reference

    • Environments
    • Playground Environment
    • Instances
    • Project image
    • Image Repository
    • Log Shipping
    • Deployment Modes
    • Altostra Cloud Integration

    Integrations

      CI/CD

      • CircleCI

      Git

      • Git integration
      • Connect a GitHub account
      • Connect a Bitbucket account

    Create a Scalable Webhook

    Overview

    In this tutorial we'll create a fully functional scalable webhook from a template. Webhooks are a design pattern for allowing one or more apps to trigger another app with real-time information when something happens (like a stock price change or a user login, for example).

    You can read more about scalable webhooks on our blog post)

    A scalable webhook consists of the following resources:

    • API Gateway to receive our calls
    • An enqueuing Lambda function to validate and write the request into the Queue
    • An SQS queue to hold all the messages until we can handle them
    • A processing Lambda function to do the actual work at the rate we need
    • A simple DynamoDB table to store our data

    Let's get started!

    Things you'll need for this tutorial

    1. An Altostra Account (Don't have one yet? Just login here)
    2. Altostra CLI installed (npm i -g @altostra/cli or see docs)
    3. Altostra extension for Visual Studio Code (VSCode Marketplace or see docs)
    4. A connected AWS cloud account ( Web Console settings or see docs)
    5. An Environment connected to your AWS Account (Web Console environments or see docs) - We'll call it Dev for berevity, but you can pick any of your environments

    Create a new project

    1. In Visual Studio Code, open the directory in which you wish to create the project.
    2. Switch to the Altostra view
    3. Click "Initialize Project"
    4. In the Templates list, click Scalable Webhook

    generate-scalable-webhook

    The template is applied to the current project, and now you've got the architecture of a scalable webhook, with basic code implementation.

    scalable-webhook-architecture

    Deploy the Project

    Now that we have the project, first we push a new image:

    $ alto push v0.1
    

    An Image is basically your infrastructure and code before they've been adapted to a specific environment. An Image can be deployed to any environment. You can read more about Altostra images here.

    And then, we deploy the project from that image to the development environment:

    $ alto deploy sampleDeployment:v0.1 --env Dev
    

    An Instance is a live release of your image in a specific environment - in this case, the Dev environment.

    For information about deploying projects, read the Deploy a Project guide.

    That's it - the project is deployed.

    deploy-scalable-webhook

    Let's Test!

    First, let's find out our api gateway address:

    Run alto console. It will take you directly to your project page in the Altostra's web console.

    Click on the instance name sampleDeploymet - and you'll get to the current deployed stack.

    Click on the arrow at the right end of the first line - this will send you directly to your AWS stack.

    Click the ApiGateway, and select the messages endpoint under Prod stage and copy the "invoke URL"

    api-gateway

    Now, lets send a sample request:

    curl --location --request POST -i 'https://3f7yjl6dd2.execute-api.us-east-1.amazonaws.com/Stage/messages' \
    --header 'Content-Type: application/json' \
    --data-raw '{
        "eventType": "CLICKED",
        "emailId": "email-1234"
    }'
    

    You should get this response:

    HTTP/2 200
    content-type: application/json
    content-length: 0
    

    Now you can go to your DynamoDB table and check for entries:

    dynamoo-db

    Congratulation! You've got a full blown working scalable webhook!

    ← Create a Static WebsiteCreate a Simple API Project →
    • Overview
    • Things you'll need for this tutorial
    • Create a new project
    • Deploy the Project
    • Let's Test!

    Ready to Get Started?

    Get Started for Free
    © 2021 Altostra, Inc.