/aws_ecs_service_connect

Guide on deploying Microservices on AWS with ECS Service Connect

Primary LanguagePythonBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Contributors Forks Stargazers Issues BSD-3-Clause License



Copyright (c) 2024, GitHub@programmingwithalex

AWS ECS Service Connect

Microservices on AWS with ECS Service Connect
View Demo · Report Bug · Request Feature

Table of Contents
  1. Series Outline
  2. Getting Started
  3. AWS (CDK) Commands
  4. References

Series Outline

  1. Get microservices example running locally using docker-compose

  2. Create working example of microservices on AWS using ECS Service Connect

    • will not be production ready
    • will rely on a lot of default values provided by AWS, with no networking setup by us
  3. Create production-ready example of microservices on AWS using ECS Service Connect

    • configure networking setup and apply that to ECS components
  4. Use GitHub Actions to automate deployments to AWS ECS components, referred to as Continuous Deployment (CD)

  5. Create networking setup and ECS components automatically with a single script using AWS CDK

(back to top)

AWS Components

  • Virtual Private Cloud (VPC)
  • NAT Gateway & Internet Gateway (IGW)
  • Elastic Container Registry (ECR)
  • Elastic Container Service (ECS)
  • ECS Clusters
  • ECS Services
  • ECS Task Definitions
  • Cloud Map
  • Application Load Balancer (ALB)
  • AWS Cloud Development Kit (CDK)
    • written in Python

(back to top)

Getting Started

Prerequisites

Software

AWS

CMD Line

  • follow setup guides for aws-cli if not already configured

(back to top)

AWS Cloud Development (CDK)

Installation (Windows)

  • download node.js, includes npm which is necessary to install the aws-cli
  • install aws-cdk
npm install -g aws-cdk

Commands

  • cdk init app --language python - create the initial CDK app locally
  • cdk bootstrap - deploying the AWS CDK for the first time
  • cdk synth - constucts CloudFormation template and does some verification checks
  • cdk deploy --all - deploy all CDK components
  • cdk destroy --all - destroys all CDK components
    • issue with calling because of Fargate Cluster dependency - FargateCluster/FargateCluster (...) Resource handler returned message: "The specified capacity provider is in use and cannot be removed.
    • if called twice then all elements will be deleted

References

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-application-load-balancer.html

If your service's task definition uses the awsvpc network mode (which is required for the Fargate launch type), you must choose IP addresses as the target type. This is because tasks that use the awsvpc network mode are associated with an elastic network interface, not an Amazon EC2 instance.

https://stackoverflow.com/questions/42715647/whats-the-target-group-port-for-when-using-application-load-balancer-ec2-con

Protocol port will be overriden by ECS anwyays so doesn't matter.

https://www.cloudkeeper.com/insight/blog/amazon-ecs-service-communication-via-service-discovery-connect

Choose client and server service if the container exposes and listens on a port for network traffic. This service gets an endpoint to communicate with any service within the same namespace

CDK Workshop

Instructions on using the AWS Cloud Development Kit (CDK)