Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

localstack-samples/localstack-pro-samples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LocalStack Pro Samples

This repository contains sample projects that can be deployed on your local machine using LocalStack Pro.

Each example in the repository is prefixed with the name of the AWS service being used. For example, the elb-load-balancing directory contains examples that demonstrate how to use the Elastic Load Balancing service with LocalStack. Please refer to the sub directories for more details and instructions on how to start the samples.

Prerequisites

Configuration

Some of the samples require LocalStack Pro features. Please make sure to properly configure the LOCALSTACK_AUTH_TOKEN environment variable. You can find your Auth Token on the LocalStack Web Application and you can refer to our Auth Token documentation for more details.

Outline

Sample Name Description
Serverless Websockets API Gateway V2 websocket APIs deployed via the Serverless framework
RDS Database Queries Running queries locally against an RDS database
Neptune Graph Database Running queries locally against a Neptune Graph database
Lambda Event Filtering Lambda event source filtering with DynamoDB and SQS
Glacier & S3 select queries Using Glacier API and running S3 Select queries locally
Cloudwatch Metrics alarm Triggering a Cloudwatch metrics alarm based on a failing Lambda
EC2 with Docker backend Running EC2 instances with Docker backend
QLDB ledger queries Running queries locally against a QLDB ledger
Cognito with JWT Running Cognito authentication and user pools locally
Transfer API with S3 Using the Transfer API to upload files to S3
Codecommit with Git repository Using the Codecommit API to create and push to a Git repository
Lambda Mounting and Debugging Debugging Lambda functions locally
IAM Policy Enforcement Enforcement of IAM policies when working with local cloud APIs
Lambda Hot Reloading Hot reloading Lambda functions locally
IoT Basics Usage of IoT APIs locally
REST API using Chalice Deploying a REST API using the Chalice framework
ECS ECR Container application Pushing Docker images to ECR and running them locally on ECS
Athena queries over S3 Running Athena queries over S3 files locally
Terraform resources Deploying various AWS resources via Terraform
Lambda Function URLs Invoking Lambda functions via HTTP(s) URLs
Sagemaker inference Creating & invoking a Sagemaker endpoint locally with MNIST dataset
MSK with Glue Schema Registry Use of MSK, Glue Schema Registry, Glue ETL, and RDS
AppSync GraphQL Deploying a GraphQL API using AppSync
Lambda XRay tracing Using Lambda XRay tracing locally
Mediastore Uploads Using MediaStore API locally
Serverless Lambda Layers Using Lambda layers locally deployed via the Serverless framework
Java Notification App Notification app using AWS Java SDK, SNS, SQS, SES, deployed via CloudFormation
Lambda Container images Deploying Lambda functions as container images
Glue crawler with RedShift Glue Crawler to populate the Glue metadata store with the table schema of RedShift database tables
API Gateway custom domain Using API Gateway v2 endpoints using custom domain names, deployed via the Serverless framework
CDK resources Deploying various AWS resources via CDK
Glue for ETL jobs Using Glue API to run local ETL jobs
Message Queue broker Using MQ API to run local message queue brokers
ELB Load Balancing Using ELBv2 Application Load Balancers locally, deployed via the Serverless framework
Reproducible ML Train, save and evaluate a scikit-learn machine learning model using AWS Lambda and S3
Lambda PHP/Bref CDK App Running PHP/Bref Lambda handler locally, deployed via AWS CDK

Checking out a single sample

To check out a single sample, you can use the following commands:

mkdir localstack-samples && cd localstack-samples
git init
git remote add origin -f git@github.com:localstack/localstack-pro-samples.git
git config core.sparseCheckout true
echo <LOCALSTACK_SAMPLE_DIRECTORY_NAME> >> .git/info/sparse-checkout
git pull origin master

The above commands use sparse-checkout to only pull the sample you are interested in. You can find the name of the sample directory in the table above.

Developer Notes

Makefiles for samples

All samples should have a Makefile to unify the execution of the otherwise heterogeneous samples. It needs to fulfill two criteria:

  • The sample should be executable independently, since it can be checked out on its own (see Checking out a single sample).
  • It should contain a test-ci target to be executed automatically within the CI pipeline. This step needs to take care of all infrastructure tasks (starting/stopping/logs/etc) in addition to any sample commands executed.

A typical Makefile looks like this:

export AWS_ACCESS_KEY_ID ?= test
export AWS_SECRET_ACCESS_KEY ?= test
export AWS_DEFAULT_REGION=us-east-1
SHELL := /bin/bash

usage:       ## Show this help
        @fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'

install:     ## Install dependencies
        @which localstack || pip install localstack
        @which awslocal || pip install awscli-local
        ## install whatever else you need, like node modules, python packages, etc.
        @test -e node_modules || npm install
        @test -e .venv || (python3 -m venv .venv; source .venv/bin/activate; pip install -r requirements.txt)

run:         ## Run the actual sample steps/commands. This assumes LocalStack is up and running.
        ./run.sh

start:       ## Start LocalStack in detached mode
        localstack start -d

stop:        ## Stop the Running LocalStack container
        @echo
        localstack stop

ready:       ## Make sure the LocalStack container is up
        @echo Waiting on the LocalStack container...
        @localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)

logs:        ## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run.
        @localstack logs > logs.txt

test-ci:     ## Execute the necessary targets in the correct order for an automatic execution. 
        make start install ready run; return_code=`echo $$?`;\
        make logs; make stop; exit $$return_code;

.PHONY: usage install run start stop ready logs test-ci