RousselTMLEARNING

TP · AWS: from discovery to expertise

Lab: A serverless API (API Gateway, Lambda, DynamoDB) on LocalStack

What you will learn in this TP
  • Design a DynamoDB table
  • Deploy a Lambda function
  • Expose a function through API Gateway

Introduction #

What you will learn in this section
  • Design a DynamoDB table
  • Deploy a Lambda function
  • Expose a function through API Gateway

Context. An internal service must store and read orders. You build a serverless API that costs nothing when idle.

Prerequisites: Docker, the AWS CLI and LocalStack (pip install localstack awscli-local terraform-local): everything runs locally, with no AWS account or charges  ·  Estimated time: 60 min

An API that creates and reads orders in DynamoDB.

Hands-on #

Guided steps, with their solution.

  1. 1. Create the table

    Why? The partition key spreads data; here an order is read by its identifier.

    Create the commandes table (key id, on-demand billing).
  2. 2. Write and deploy the function

    Why? The function reads the HTTP method from the API Gateway event and acts on the table.

    Write app.py (POST creates an order, GET reads it), zip it and create the function.
  3. 3. Expose through an HTTP API

    Why? API Gateway routes HTTP requests to the function.

    Create an HTTP API with POST /commandes and GET /commandes/{id} routes integrated with the function.
  4. 4. Test and observe

    Why? Function logs reach CloudWatch Logs, just as on AWS.

    Create an order, read it back, request an unknown id and check the logs.

Difficulty level : ●●●○○ (3/5)

My progress

  • ⏱ Estimated time : ≈ 1 h

Sign in to track your progress and take notes. Sign in

💬 Ask a question

Recommended Articles

Le calcul sur AWS : EC2, Auto Scaling, Lambda et conteneurs

Choisir et utiliser les services de calcul AWS : instances EC2 (types, AMI, EBS, user data, modèl...

Les bases de données sur AWS : RDS, Aurora, DynamoDB et ElastiCache

Choisir une base de données managée sur AWS : RDS et Aurora pour le relationnel (multi-AZ, réplic...

Informatique serverless : définition, FaaS et cas d'usage

L'informatique serverless expliquée : Function as a Service (FaaS), fonctionnement, avantages, li...

Le réseau AWS : VPC, sous-réseaux, routage et sécurité

Concevoir un réseau AWS : VPC et plages CIDR, sous-réseaux publics et privés, tables de routage, ...

Kubernetes : exposer ses applications (Services, Ingress et Gateway API)

Exposer des applications dans Kubernetes : Services ClusterIP/NodePort/LoadBalancer, Ingress, Ing...

Comprendre AWS : infrastructure mondiale, comptes, outils et tarification

Les bases indispensables pour démarrer sur Amazon Web Services : régions, zones de disponibilité ...

Le stockage sur AWS : S3, EBS, EFS et sauvegarde

Stocker des données sur AWS : Amazon S3 (buckets, classes de stockage, versionnage, cycle de vie,...

Infrastructure as Code sur AWS : CloudFormation, CDK, Terraform et Well-Architected

Décrire et déployer son infrastructure AWS en code avec CloudFormation, le CDK ou Terraform, auto...

Terraform sur plusieurs clouds : AWS, Azure, Google Cloud, OVHcloud et Kubernetes

Utiliser Terraform avec les principaux fournisseurs : aws, azurerm, google, ovh et openstack, kub...

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!