Sample AWS microservices app with service discovery defined using the CDK. Uses Docker + Fargate & ELB.

Overview

AWS Microservices Demo with CDK and Fargate

About

Simple AWS microservice-based app.

Consists of two Spring Boot based services:

  • Name Service

    • GET /name/{some_name}
      • Concatenates {some_name} with the last name of a US president
      • Returns { "name": "some_name some_presidents_last_name" }
    • GET /hello/internal/health
      • Health check endpoint for ELB
  • Hello World Service

    • GET /hello/{some_name}
      • Uses ELB based service discovery to call name service and says hello to the returned full-name
      • Returns { "hello": "some_name some_presidents_last_name" }
    • GET /hello/internal/health
      • Health check endpoint for ELB

Technology

  • AWS
    • ECS/Fargate
    • Elastic Load Balancer
    • CDK (TypeScript)
  • Java
    • Spring Boot

Architecture

Requirements

  • Java 11
  • TypeScript
  • Maven
  • NPM
  • Docker
  • AWS CLI
  • AWS CDK
  • Git Bash or WSL if using Windows

Build

Build docker images:

Navigate to /infrastructure/scripts

Run: bash build-images.sh

Verify Build

Open two new terminals:

Navigate to /infrastructure/scripts/local

Run:

bash run-name-service.sh

bash run-hello-world-service.sh

Open:

http://localhost:8081/hello/nick

You should see a JSON response with the following format:

{"hello":"nick Clinton"}

Deploy

Create ECR Repository on AWS for Images

Run:

aws ecr create-repository --repository-name aws-fargate-demo

Push Images to AWS ECR Repository

Navigate to /infrastructure/scripts

Run:

bash ecr-deploy-sh

  • Enter your AWS Credentials and the name of the ECR repository you created
  • When prompted for image id, copy the image ID of the repository with name aws-fargate-demo/name-service
  • When prompted for image name, type name-service
  • Reply y when asked if you want to delete previous images if you would like to avoid extra costs, n otherwise
  • Repeat for hello-world-service

Create AWS Infrastructure

Navigate to /infrastructure

Install dependencies: npm install

Deploy infrastructure: cdk deploy

Verify Deploy

Run:

aws elbv2 describe-load-balancers

Copy the DNS name of the created load balancer

Navigate to:

http://DNS_NAME_GOES_HERE/hello/nick

In my case:

http://awsfa-awsfa-wg458r9ycnd8-2128681189.us-east-1.elb.amazonaws.com/hello/nick

You should see a JSON response with the following format:

{"hello":"nick Clinton"}

Cleanup

Delete ECR Repository and Images

aws ecr delete-repository --repository-name aws-fargate-demo --force

Delete infrastructure

cdk destroy

You might also like...

AWS Lambda & Serverless - Developer Guide with Hands-on Labs. Develop thousands line of aws lambda functions interact to aws serverless services with real-world hands-on labs

AWS Lambda & Serverless - Developer Guide with Hands-on Labs. Develop thousands line of aws lambda functions interact to aws serverless services with real-world hands-on labs

AWS Lambda & Serverless - Developer Guide with Hands-on Labs UDEMY COURSE WITH DISCOUNTED - Step by Step Development of this Repository - https://www

Dec 17, 2022

A monorepo that uses the AWS Cloud Development Kit to deploy and configure nanomdm on AWS lambda.

NanoMDM on AWS This repo builds and configures a nanomdm server to run on AWS lambda. It uses the Cloud Development Kit and tries to follow best pract

May 26, 2022

a stack-separated way to bringing together common AWS services useful in a fullstack application that uses AWS Amplify libraries

Fullstack CDK Helpers This project helps developers create common AWS services that are useful in creating fullstack applications. Backend services ar

Nov 26, 2022

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

serverless dynamodb integration tests 🚀 Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK Introduction How to inte

Nov 4, 2022

This project provides a CDK construct creating AWS organizations.

AWS Organizations This project provides a CDK construct creating AWS organizations. Currently, there is no @aws-cdk/aws-organizations available. See t

Dec 29, 2022

Easy-to-use CDK constructs for monitoring your AWS infrastructure

CDK Monitoring Constructs Easy-to-use CDK constructs for monitoring your AWS infrastructure. Easily add commonly-used alarms using predefined properti

Jan 6, 2023

AWS CDK compiled for web (and Node!)

cdk-web 🚀 DEMO 💪 AWS CDK compiled for web (and Node!) cdk-web and aws-cdk-web are functionally identical packages on npm. read about the differences

Dec 5, 2022

Functionless-based mini-framework for DynamoDB migrations in AWS CDK.

dynamodb-migrations This repo is heavily in progress! Readme describes desired contract and functionality. Please do not try using it yet!. I'm not ev

Dec 20, 2022

AWS CDK stack for taking website screenshots (powered by Puppeteer)

CDK Screenshot (powered by Puppeteer) Made possible by the excellent Puppeteer. Install export AWS_PROFILE=myprofile export AWS_DEFAULT_REGION=us-east

Oct 23, 2022
Owner
Nick Klaene
Nick Klaene
Learn Web 2.0 and Web 3.0 Development using Next.js, Typescript, AWS CDK, AWS Serverless, Ethereum and AWS Aurora Serverless

Learn Web 2.0 Cloud and Web 3.0 Development in Baby Steps In this course repo we will learn Web 2.0 cloud development using the latest state of the ar

Panacloud Multi-Cloud Internet-Scale Modern Global Apps 89 Jan 3, 2023
A sample code that implements a simple Web app using AWS CDK v2

A sample code that implements a simple Web app using AWS CDK v2. This code will be introduced in a live coding session at AWS Summit Online Japan 2022 Developer Zone in 2022/5/25.

AWS Samples 29 Dec 5, 2022
Sample code for resizing Images with Lambda@Edge using the Custom Origin. You can deploy using AWS CDK.

Resizing Images with Lambda@Edge using the Custom Origin You can resize the images and convert the image format by query parameters. This Lambda@Edge

AWS Samples 16 Dec 11, 2022
A sample CICD Deployment Pipeline for your Alexa Skills, using AWS CDK, CodeBuild and CodePipeline

Alexa Skils - CI/CD CDK Pipeline This repository will help you setting up a CI/CD pipeline for your Alexa Skills. This pipeline is powered by AWS Clou

null 5 Nov 23, 2022
Under the Sea is an official AWS workshop delivered by AWS SAs and AWS Partners to help customers and partners to learn about AIOps with serverless architectures on AWS.

Under the Sea - AIOps with Serverless Workshop Under the Sea is an exciting MMORPG developed by the famous entrepreneur behind Wild Rydes, the most po

AWS Samples 4 Nov 16, 2022
An AWS Cloud Native application using CDK that defines a Serverless Event Driven application for interacting with Twitter and utilising Machine Learning / AI as a Service.

AWS Serverless Event Driven Twitter Bot An AWS Cloud Native application using CDK (Written in TypeScript) that defines a Serverless Event Driven appli

null 4 Dec 18, 2022
An Amazon Kendra REST API CDK example with an API Gateway, including authentication with AWS Cognito and AWS X-Ray Tracing

Amazon Kendra Web Service CDK Sample Amazon Kendra has a robust JSON API for use with the AWS SDK (software development kit), but does not expose endp

AWS Samples 8 Nov 28, 2022
A simple web server exposing Hetzner cloud instances for consumption by the Prometheus HTTP service discovery.

Prometheus: Hetzner Service Discovery A server to provide automatic node discovery for Hetzner Cloud to Prometheus via HTTP service discovery. In cont

Matchory GmbH 1 Oct 10, 2022
MerLoc is a live AWS Lambda function development and debugging tool. MerLoc allows you to run AWS Lambda functions on your local while they are still part of a flow in the AWS cloud remote.

MerLoc MerLoc is a live AWS Lambda function development and debugging tool. MerLoc allows you to run AWS Lambda functions on your local while they are

Thundra 165 Dec 21, 2022