JAWS Pankration 2021 - DDD on AWS Lambda sample

Overview

JAWS Pankration 2021 - DDD on AWS Lambda sample

What is this project?

This project contains sample code for AWS Lambda with domain models. I presented the session about how to implement an AWS Lambda function with domain models at JAWS Pankration 20201. This repository shows you how to implement your domain models, ports and adapters classes on AWS Lambda function. This project includes sample domain models regarding a vaccination reservation system and these are loosly coupled from infrastructure code such as accessing a DynamoDB table using ports and adapters classes. This application is designed by concept of hexagonal architecture or ports and adapters architecture by Alistair Cockburn. This application also uses injector Python library to inject ports and adapters classes. It elables you to execute unit testing more easily because you can inject dummy instances into target classes. For more details, see sample unit testing code in this project. (./tests/unit folder)

Domain Models

Domain Models

Sequence diagram for this application

Sequence diagram

Serverless Application Model

This project contains source code and supporting files for a serverless application that you can deploy with the SAM CLI. It includes the following files and folders.

  • src - Code for the application's Lambda function.
  • events - Invocation events that you can use to invoke the function.
  • tests/unit - Unit tests for the application code.
  • template.yaml - A template that defines the application's AWS resources.

Deploy the sample application

The Serverless Application Model Command Line Interface (SAM CLI) is an extension of the AWS CLI that adds functionality for building and testing Lambda applications. It uses Docker to run your functions in an Amazon Linux environment that matches Lambda. It can also emulate your application's build environment and API.

To use the SAM CLI, you need the following tools.

To build and deploy your application for the first time, run the following in your shell:

sam build --use-container
sam deploy --guided

The first command will build the source of your application. The second command will package and deploy your application to AWS, with a series of prompts:

You can find your API Gateway Endpoint URL in the output values displayed after deployment.

Prepare DynamoDB data before you execute this function

When you execute this function you need to execute data prepare script.

$ chmod +x setup/add_ddb_data.sh
$ setup/add_ddb_data.sh

Use the SAM CLI to build and test locally

Build your application with the sam build --use-container command.

vaccination_reservation_demo$ sam build --use-container

The SAM CLI installs dependencies defined in src/requirements.txt, creates a deployment package, and saves it in the .aws-sam/build folder.

Test a single function by invoking it directly with a test event. An event is a JSON document that represents the input that the function receives from the event source. Test events are included in the events folder in this project.

Run functions locally and invoke them with the sam local invoke command.

vaccination_reservation_demo$ sam local invoke HelloWorldFunction --event events/event.json

Tests

Tests are defined in the tests folder in this project. Use PIP to install the test dependencies and run tests.

vaccination_reservation_demo$ pip install -r tests/requirements.txt --user
# unit test
vaccination_reservation_demo$ python -m pytest tests/unit -v
# integration test, requiring deploying the stack first.
# Create the env variable AWS_SAM_STACK_NAME with the name of the stack we are testing
vaccination_reservation_demo$ AWS_SAM_STACK_NAME=<stack-name> python -m pytest tests/integration -v

Cleanup

To delete the sample application that you created, use the AWS CLI. Assuming you used your project name for the stack name, you can run the following:

aws cloudformation delete-stack --stack-name vaccination_reservation_demo

Resources

See the AWS SAM developer guide for an introduction to SAM specification, the SAM CLI, and serverless application concepts.

Next, you can use AWS Serverless Application Repository to deploy ready to use Apps that go beyond hello world samples and learn how authors developed their applications: AWS Serverless Application Repository main page

Owner
Atsushi Fukui
Amazon Web Services Japan Senior Solutions Architect / Serverless Specialist. Opinions Are My Own. このリポジトリに含まれる内容は個人の見解であり所属する団体とは関係ありません。また一切の動作の保証はいたしません。
Atsushi Fukui
Upload comma-delimited files to biglocalnews.org in your GitHub Action

Upload comma-delimited files to biglocalnews.org in your GitHub Action Inputs api-key: Your biglocalnews.org API token. project-id: The identifier of

biglocalnews 1 Apr 20, 2022
Get notifications in your Discord server of any software releases from Apple.

Apple Releases Get notifications in your Discord server of any software releases from Apple. Running To locally host your own instance, create a Disco

adam 17 Oct 22, 2022
Send alert to telegram use telegram cli

Run standalone: Rename conf.yml.example to conf.yml Change block cli(Add your api_id and hash) Install requirements.txt Run python AlertManagerTG.py I

Eugene Arkharov 1 Nov 12, 2021
Scrapping malaysianpaygap & Extracting data from the Instagram posts

Scrapping malaysianpaygap & Extracting data from the posts Recently @malaysianpaygap has gotten quite famous as a platform that enables workers throug

Yudhiesh Ravindranath 65 Nov 09, 2022
Using twitter lists as your feed

Twitlists A while ago, Twitter changed their timeline to be algorithmically-fed rather than a simple reverse-chronological feed. In particular, they p

Peyton Walters 5 Nov 21, 2022
A Bot to Track Kernel Upstreams from kernel.org and Post it on Telegram Channel

Channel Kernel Tracker is the channel where the bot will be sending the updates in. Introduction This is a Telegram Bot to Track Kernel Upstreams kern

Kartikeya Hegde 3 Oct 05, 2021
Kanata Bot - a modular bot running on python3 with anime theme and have a lot features

Kanata Bot Kanata Bot is a modular bot running on python3 with anime theme and have a lot features. Easiest Way To Deploy On Heroku This Bot is Create

Rikka-Chan 2 Jan 16, 2022
Some examples regarding how to use the Twitter APIs for academic research

Twitter Developer Platform: Using Twitter APIs for Academic Research All the scripts require a config.ini file in which the keys are put. There is a t

Federico Bianchi 6 Feb 13, 2022
AWS SQS event redrive Lambda With Python

AWS SQS event redrive Lambda This repository contains one simple AWS Lambda function in Python to redrive AWS SQS events from source queue to destinat

1 Oct 19, 2021
A simple Telegram bot that analyses a given word, built with python-telegram-bot

Telegram Word Bot A simple Telegram bot that analyses a given word, built with python-telegram-bot. The bot is fairly useless - unless you often need

Chris N 2 Jul 14, 2022
An script where it logs in your instagram account and follows people and likes their posts

InstaFollower An script where it logs in your instagram account and follows people and likes their posts (uses the tags to fetch people) Requirements:

Bless 3 Nov 29, 2022
Tools to help record data from Qiskit jobs

archiver4qiskit Tools to help record data from Qiskit jobs. Install with pip install git+https://github.com/NCCR-SPIN/archiver4qiskit.git Import the

0 Dec 10, 2021
SimpleTelegramScraper - A python script scrapes accounts from public groups via Telegram API and saves them in a CSV file

SimpleTelegramScraper - the best scraper on GitHub This simple python script scr

Deniz Shabani 12 Oct 06, 2022
Mandatory join to channel using pyTelegramBotAPI

Running set your bot token to config.py set channel username to config.py set channel url to config.py $ python join.py Attention Bot must be administ

Abdulatif 6 Oct 08, 2022
Currency And Gold Prices - Currency And Gold Prices For Python

Currency_And_Gold_Prices Photos from the app New Update Show range Change better

Ali HemmatNia 4 Sep 19, 2022
Python client for the Echo Nest API

Pyechonest Tap into The Echo Nest's Musical Brain for the best music search, information, recommendations and remix tools on the web. Pyechonest is an

The Echo Nest 655 Dec 29, 2022
A simple fun discord bot using discord.py that can post memes

A simple fun discord bot using discord.py * * Commands $commands - to see all commands $meme - for a random meme from the internet $cry - to make the

Dice Flip 2 Dec 20, 2021
Presentation and code files for the talk at PyCon Indonesia

pycon-indonesia Presentation and code files for the talk at PyCon Indonesia. Files used for the PyCon Indonesia presentation. [Directory Includes:] Be

Neeraj Pandey 2 Dec 04, 2021
An API Wrapper for Gofile API

Gofile2 from gofile2 import Gofile g_a = Gofile() print(g_a.upload(file="/home/itz-fork/photo.png")) An API Wrapper for Gofile API. About API Gofile

I'm Not A Bot #Left_TG 16 Dec 10, 2022
Remedy when Amazon ECR is not running basic scans for container CVEs.

Welcome to your CDK Python project! This is a blank project for Python development with CDK. The cdk.json file tells the CDK Toolkit how to execute yo

4n6ir 4 Nov 05, 2022