All Projects → smallcase → aws-cdk-microservice

smallcase / aws-cdk-microservice

Licence: Apache-2.0 license
An AWS CDK Construct to deploy microservice infra in less than 50 lines of code.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aws-cdk-microservice

cloudpatrol
Policy as Code for the Cloud Development Kit (CDK)
Stars: ✭ 21 (-56.25%)
Mutual labels:  cdk
cdk-github-actions-runner
Deploy self-hosted GitHub Actions runner to AWS Fargate using AWS Cloud Development Kit (CDK)
Stars: ✭ 89 (+85.42%)
Mutual labels:  cdk
cdk pywrapper
A Python wrapper for the Chemistry Development Kit (CDK)
Stars: ✭ 25 (-47.92%)
Mutual labels:  cdk
valheim-ecs-fargate-cdk
AWS CDK/Cloudformation to deploy a Valheim Server using ECS Fargate!
Stars: ✭ 66 (+37.5%)
Mutual labels:  cdk
aws-usage-queries
This application bootstraps everything needed to query the AWS Cost and Usage reports through Amazon Athena. It also includes reference data and preconfigured SQL queries.
Stars: ✭ 28 (-41.67%)
Mutual labels:  cdk
cloudfront-image-proxy
Make CloudFront resize images "on the fly" via lambda@edge, cache it and persists it in S3.
Stars: ✭ 32 (-33.33%)
Mutual labels:  cdk
aws-ecs-devops-using-aws-cdk
This repository provides a general DevOps practices such MSA, IaC, CICD and Monitoring. AWS various services are used to provide DevOps best practices.
Stars: ✭ 110 (+129.17%)
Mutual labels:  cdk
cdk-ecr-deployment
A CDK construct to deploy docker image to Amazon ECR
Stars: ✭ 51 (+6.25%)
Mutual labels:  cdk
cdk-multi-profile-plugin
Adds multi profile/account, mfa and aws sso support to cdk apps
Stars: ✭ 41 (-14.58%)
Mutual labels:  cdk
cli
Panacloud Command Line Interface (CLI) uses the design-first approach for developing APIs. It generates Modern Multi-Tenant Serverless Cloud API infrastructure, mocks, stubs, tests, and stages using CDK. GraphQL schemas and OpenAPI specifications are used to implement the design-first approach.
Stars: ✭ 23 (-52.08%)
Mutual labels:  cdk
cdk-eventbridge-socket
CDK construct that creates a WebSocket endpoint for you for any EventBridge rule you are interested in. (Built for debugging + testing )
Stars: ✭ 43 (-10.42%)
Mutual labels:  cdk
rds-snapshot-export-to-s3-pipeline
RDS Snapshot Export to S3 Pipeline
Stars: ✭ 88 (+83.33%)
Mutual labels:  cdk
cdk-examples
AWS CDK Examples Repository
Stars: ✭ 49 (+2.08%)
Mutual labels:  cdk
cdk-esbuild
CDK constructs for esbuild, an extremely fast JavaScript bundler
Stars: ✭ 44 (-8.33%)
Mutual labels:  cdk-construct
simple-nft-marketplace
This project provides sample codes to build a simple NFT marketplace with Amazon Managed Blockchain.
Stars: ✭ 59 (+22.92%)
Mutual labels:  cdk
document-understanding-solution
Example of integrating & using Amazon Textract, Amazon Comprehend, Amazon Comprehend Medical, Amazon Kendra to automate the processing of documents for use cases such as enterprise search and discovery, control and compliance, and general business process workflow.
Stars: ✭ 180 (+275%)
Mutual labels:  cdk
django-cdk
A CDK library that provides high-level constructs for hosting Django applications on AWS
Stars: ✭ 31 (-35.42%)
Mutual labels:  cdk
aws-cdk-github-oidc
CDK constructs to use OpenID Connect for authenticating your Github Action workflow with AWS IAM
Stars: ✭ 59 (+22.92%)
Mutual labels:  cdk
cdkdx
Zero-config CLI for aws cdk development
Stars: ✭ 31 (-35.42%)
Mutual labels:  cdk
aws-firewall-factory
Deploy, update, and stage your WAFs while managing them centrally via FMS.
Stars: ✭ 72 (+50%)
Mutual labels:  cdk

aws-cdk-microservice

aws-cdk-microservice construct library is an open-source extension of the AWS Cloud Development Kit (AWS CDK) to deploy configurable microservice infra and its individual components in less than 50 lines of code and human readable configuration which can be managed by pull requests!

A typical microservice architecture on AWS looks like:

Architecture diagram

Using cdk a microservice can be deployed using the following sample code snippet:

import { Stack, StackProps } from '@aws-cdk/core';
import { Construct } from 'constructs';
import { MicroService } from '@smallcase/aws-cdk-microservice';
import { App } from '@aws-cdk/core';

export class UnknownAPIStackDev extends Stack {
 constructor(scope: Construct, id: string, props?: StackProps) {
   super(scope, id, props);
   new MicroService(this, 'test', {
     appName: 'test',
     env: 'prod',
     asgMaxSize: '1',
     asgMinSize: '1',
     diskSize: 20,
     instanceLabels: [
       {
         key: 'SUDOERS_GROUPS_TAG',
         propagateAtLaunch: true,
         value: 'Developers',
       },
     ],
     instanceType: 't3.micro',
     vpc: 'vpc-1234567',
     role: {
       type: 'existing',
       roleArn: 'arn:aws:iam::123456789233:instance-profile/API-DEV',
     },
     sshKey: 'master-dev',
     subnets: ['subnet-12345678', 'subnet-123456789'],
     tcpRules: [
       {
         sourceSG: 'sg-12345678',
         description: 'ssh rule',
         port: 22,
       },
       {
         sourceSG: 'sg-987654321',
         description: 'from load balancer',
         port: 8000,
       },
     ],
     networkProps: [
       {
         healthCheckPath: '/health',
         host: 'abc-test-123.smallcase.com',
         lbArn: 'arn:aws:elasticloadbalancing:ap-south-1:123456789233:loadbalancer/app/API-DEV-External',
         sslEnabled: false,
         port: 8000,
         protocol: 'HTTP',
         zoneName: 'smallcase.com',
         zoneId: '1234567891011'
       },
     ],
     createCodedeployApplication: true,
   });
 }
}

new UnknownAPIStackDev(app, 'UnknownAPIStackDev', {
 env: { account: '12345678910', region: 'ap-south-1' },
});

app.synth()

Please refer here to check how to use individual resource constructs.

Install using NPM:

npm install @smallcase/aws-cdk-microservice

Using yarn

yarn add @smallcase/aws-cdk-microservice

Configuration helper

Property Type Default Description
appName string Name of the application to be deployed
applicationType? string new Type of application, new or existing, if existing, codedeploy will skip it's application creation and create a deployment group in existing application.
asgMaxSize? number 2 Max ASG scale size
asgMinSize? number 1 Min ASG scale size
env? string development Application environment name
instanceLabels? CfnAutoScalingGroup.TagPropertyProperty[] [] Tags to apply to the stack
healthCheckPath? string /health Health check path for target group
port? number undefined Port on which application is running. If not passed, target group will not be created
protocol? string (HTTP/HTTPS/GRPC) HTTP Service protocol
diskSize? number 8GB Size of root volume for launch template
vpc string VPC in which application infra is to be deployed
role? string Role ARN which is to be used with launch template
tcpRules IngressRule[] [] TCP Rules which are to be applied to the security group
subnets string[] Subnets in which subnets are to be deployed
sslEnabled? boolean false Whether to use HTTPS ALB listener, or HTTP ALB listener
host? string DNS name, for example abc.xyz.com. Won't be created if TG is not created,
lbArn? string Load balancer arn for application load balancing
sshKey string The ssh key pair name which is to be used
diskType? string (GP2/GP3/IO1/IO2) GP3 Type of disk to be used
createCodedeployApplication? boolean false Whether to create a codedeploy application and a deployment group for current ENV passed, if applicationType is new, this will not create an application but will create a new deployment group in the same application name, will throw an error if not found.
deploymentPolicies? string[] [] Deployment group policies which are to be passed, there are major policies already attached which will allow usage of S3 and triggering codedeploy agents on instances.

Bootstrap the environment

cdk bootstrap

Check the changed which are to be deployed

~ -> cdk diff
Stack my-stack-dev
...
IAM Policy Changes
┌───┬──────────────────────────────────────────────────────────────────────────────┬────────────────────────────────────────────────────────────────────┐
│   │ Resource                                                                     │ Managed Policy ARN                                                 │
├───┼──────────────────────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────────┤
│ + │ ${UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stackRole} │ arn:aws:iam::aws:policy/service-role/AmazonEC2SpotFleetTaggingRole │
│ + │ ${UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stackRole} │ arn:aws:iam::aws:policy/ReadOnlyAccess                             │
│ + │ ${UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stackRole} │ arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM           │
│ + │ ${UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stackRole} │ arn:aws:iam::aws:policy/AmazonEC2FullAccess                        │
└───┴──────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────┘
Security Group Changes
┌───┬─────────────────────────────────────────────────────────────────────────────────────┬─────┬────────────┬─────────────────┐
│   │ Group                                                                               │ Dir │ Protocol   │ Peer            │
├───┼─────────────────────────────────────────────────────────────────────────────────────┼─────┼────────────┼─────────────────┤
│ + │ ${UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stack-sg.GroupId} │ In  │ TCP 22     │ sg-12346578     │
│ + │ ${UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stack-sg.GroupId} │ Out │ Everything │ Everyone (IPv4) │
└───┴─────────────────────────────────────────────────────────────────────────────────────┴─────┴────────────┴─────────────────┘
(NOTE: There may be security-related changes not in this list. See https://github.com/aws/aws-cdk/issues/1299)

Resources
[+] AWS::EC2::SecurityGroup UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stack-sg UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPIASGstacksg858F9DBC 
[+] AWS::EC2::SecurityGroupIngress UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stack-sg/from mystackdevUnknownAPIdevelopmentUnknownAPIassgf9c56492221D098D02:22 UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPIASGstacksgfrommystackdevUnknownAPIdevelopmentUnknownAPIassgf9c56492221D098D0222498F0E3E 
[+] AWS::IAM::Role UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stackRole UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPIASGstackRole3CEFE0B7 
[+] AWS::IAM::Policy UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG-stackRole/DefaultPolicy UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPIASGstackRoleDefaultPolicy8F61E954 
[+] AWS::IAM::InstanceProfile UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-LT/Profile UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPILTProfileC84DF85A 
[+] AWS::EC2::LaunchTemplate UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-LT UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPILT3B54AB26 
[+] AWS::ElasticLoadBalancingV2::TargetGroup UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-TG UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPITG141FD907 
[+] AWS::AutoScaling::AutoScalingGroup UnknownAPI/development-UnknownAPI-as/development-UnknownAPI-ASG UnknownAPIdevelopmentUnknownAPIasdevelopmentUnknownAPIASGEC1B4F9C 
[+] AWS::IAM::Role UnknownAPI/UnknownAPI-deployment-group-role UnknownAPIUnknownAPIdeploymentgrouprole6E048442 
[+] AWS::IAM::Policy UnknownAPI/UnknownAPI-deployment-group-role/DefaultPolicy UnknownAPIUnknownAPIdeploymentgrouproleDefaultPolicy176FEC37 
[+] AWS::CodeDeploy::Application UnknownAPI/development-UnknownAPI-cd/UnknownAPI-development UnknownAPIdevelopmentUnknownAPIcdUnknownAPIdevelopment72A04EEC 
[+] AWS::CodeDeploy::DeploymentGroup UnknownAPI/development-UnknownAPI-cd/development UnknownAPIdevelopmentUnknownAPIcddevelopmentC502CFAD 

this is a trimmed output.

Deploy using

~ -> cdk deploy
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].