All Projects → aws-samples → aws-serverless-using-aws-cdk

aws-samples / aws-serverless-using-aws-cdk

Licence: MIT-0 license
This repository provides the basic patterns of AWS Serverless using AWS CDK.

Programming Languages

typescript
32286 projects
python
139335 projects - #7 most used programming language
shell
77523 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aws-serverless-using-aws-cdk

amazon-cognito-example-for-external-idp
An example for using Amazon Cognito together with an external IdP
Stars: ✭ 222 (+455%)
Mutual labels:  amazon-api-gateway, aws-cdk
amazon-eventbridge-cdk-audit-service-sample
Sample of a decoupled audit service using Amazon EventBridge and AWS Step Functions. Provisioned with AWS CDK.
Stars: ✭ 25 (-37.5%)
Mutual labels:  amazon-dynamodb, aws-cdk
document-processing-pipeline-for-regulated-industries
A boilerplate solution for processing image and PDF documents for regulated industries, with lineage and pipeline operations metadata services.
Stars: ✭ 36 (-10%)
Mutual labels:  amazon-dynamodb, aws-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 (+350%)
Mutual labels:  aws-cdk
aws-step-functions-plagiarism-demo-dotnetcore
A simple workflow for developing AWS Step Functions to demonstrate how you can combine AWS Step Functions with AWS Lambda using .NET 6 and the Serverless Application Model (SAM), and expose your workflow via an API Gateway!
Stars: ✭ 58 (+45%)
Mutual labels:  aws-serverless
nexus-oss-on-aws
Deploy Sonatype Nexus Repository OSS on AWS with well architecture.
Stars: ✭ 51 (+27.5%)
Mutual labels:  aws-cdk
aws-cdk-github-oidc
CDK constructs to use OpenID Connect for authenticating your Github Action workflow with AWS IAM
Stars: ✭ 59 (+47.5%)
Mutual labels:  aws-cdk
data-lake-as-code
Data Lake as Code, featuring ChEMBL and OpenTargets
Stars: ✭ 133 (+232.5%)
Mutual labels:  aws-cdk
patterns-serverless-rust
Production-ready setup for starting with serverless Rust + GraphQL + DynamoDB on AWS Lambda using AWS CDK for deployment
Stars: ✭ 15 (-62.5%)
Mutual labels:  aws-cdk
cdk-py-k8s-the-real-hard-way-aws
Python CDK code for "Kubernetes The (real) Hard Way (AWS)"
Stars: ✭ 14 (-65%)
Mutual labels:  aws-cdk
cdk-aurora-globaldatabase
Use AWS CDK Create Aurora Global Database
Stars: ✭ 17 (-57.5%)
Mutual labels:  aws-cdk
ses-email-forwarding
AWS CDK constructs to receive emails with SES and forward them to any other email address.
Stars: ✭ 17 (-57.5%)
Mutual labels:  aws-cdk
cloudpatrol
Policy as Code for the Cloud Development Kit (CDK)
Stars: ✭ 21 (-47.5%)
Mutual labels:  aws-cdk
patterns-serverless-scala-minimal
Production-ready setup for starting with serverless Scala on AWS Lambda using AWS CDK for deployment
Stars: ✭ 23 (-42.5%)
Mutual labels:  aws-cdk
serverless
Serverless Erlang runtime for AWS Lambda Service
Stars: ✭ 27 (-32.5%)
Mutual labels:  aws-cdk
aws-lambda-decorators
A set of Python decorators to simplify AWS lambda development
Stars: ✭ 19 (-52.5%)
Mutual labels:  amazon-lambda
aws-codecommit-devops-model
AWS CodeCommit Devops Model -- a best practice to build your devops workflow based on AWS CodeCommit.
Stars: ✭ 30 (-25%)
Mutual labels:  aws-cdk
rds-snapshot-export-to-s3-pipeline
RDS Snapshot Export to S3 Pipeline
Stars: ✭ 88 (+120%)
Mutual labels:  aws-cdk
patterns-serverless-rust-minimal
Production-ready setup for starting with serverless Rust on AWS Lambda using AWS CDK for deployment
Stars: ✭ 51 (+27.5%)
Mutual labels:  aws-cdk
polynimbus
Multi-cloud infrastructure inventory and management tool, supporting AWS, Google Cloud, Azure, Oracle Cloud, Rackspace Cloud, Hetzner Cloud, Alibaba Cloud, e24cloud.com, Linode, Cloudflare, GoDaddy and Backblaze B2.
Stars: ✭ 70 (+75%)
Mutual labels:  amazon-lambda

AWS Serverless using AWS CDK

This repository describes how to implement basic patterns of AWS Serverless using AWS CDK. AWS CDK is a great tool for serverless applications because it helps you manage multiple serverless resources in one place.

Korean practice guide and demo is provided through the following video: AWS DevAxConnect - AWS Serverless service development with AWS CDK.

This project was implemented based on AWS CDK Project Template for DevOps for more fluent DevOps application.

Other "Using AWS CDK" series can be found in:

Contents

  1. Repository structure

  2. Solution coverage

  3. Solution architecture

  4. How to deploy

  5. How to test

  6. About CDK-Project

  7. How to clean up

  8. Security

  9. License

Repository structure

Because this repository is basically a CDK-Project which is based on typescript, the project structure follows the basic CDK-Project form. This porject provide one stack and 3 lambdas. Before depoy this project, config/app-config.json should be filled in according to your AWS Account.

ProjectStructure

Solution coverage

This repository introduces the common patterns of AWS Serverless.

  • pattern 1: Amazon SNS -> Amazon Lambda -> Amazon DynamoDB
  • pattern 2: Amazon S3 -> Amazon Lambda -> Amazon DynamoDB
  • pattern 3: Amazon API Gateway -> Amazon Lambda -> Amazon DynamoDB

Solution architecture

Specifically, it is implemented assuming that we are developing a book catalog service for easy understanding.

  • flow 1: Async Single Request(Request to save one book)
  • flow 2: Async Batch Request(Request to save a large of books)
  • flow 3: Sync Single Request(Request for a list of books)

SolutionArchitecture

AWS services used are as follows:

How to deploy

To efficiently define and provision serverless resources, AWS Cloud Development Kit(CDK) which is an open source software development framework to define your cloud application resources using familiar programming languages is utilized .

AWSCDKIntro

Because this solusion is implemented in CDK, we can deploy these cloud resources using CDK CLI. Among the various languages supported, this solution used typescript. Because the types of typescript are very strict, with the help of auto-completion, typescrip offers a very nice combination with AWS CDK.

Caution: This solution contains not-free tier AWS services. So be careful about the possible costs. Fortunately, serverless services minimize cost if not used.

Prerequisites

First of all, AWS Account and IAM User is required. And then the following must be installed.

  • AWS CLI: aws configure --profile [profile name]
  • Node.js: node --version
  • AWS CDK: cdk --version
  • jq: jq --version

Please refer to the kind guide in CDK Workshop.

How to set up

First of all, enter your project basic configuration in the follwoing document: config/app-config.json. Fill in your project's "Name", "Stage", "Account", "Region", "Profile(AWS CLI Credentials)" in "Project" according to your environments.

{
    "Project": {
        "Name": "ServerlessCdk",
        "Stage": "Demo",
        "Account": "75157*******",
        "Region": "us-east-2",
        "Profile": "cdk-demo"
    }
}

If you don't know AWS Account/Region, execute the following commands to catch your AWS-Account.

aws sts get-caller-identity --profile [your-profile-name]
...
...
{
    "Account": "[account-number]", 
    "UserId": "[account-id]", 
    "Arn": "arn:aws:iam::75157*******:user/[iam-user-id]"
}

And then execute the following commands to set up CDK-Project. For details, please check setup_initial.sh file.

sh ./script/setup_initial.sh  

How to provision

Let's check stack included in this CDK-Project before provisining. Execute the following command. The prefix "ServerlessCdkDemo" can be different according to your setting(Project Name/Stage).

cdk list
...
...
ServerlessCdkDemo-ServerlessStack

Now, everything is ready, let's provision all stacks using AWS CDK. Execute the following command which will deploy all stacks in order of subordination.

sh script/deploy_stacks.sh

How to test

For Async Single Request, execute the following command, which will publish SNS message(script/input_sns.json) and finally the lambda functions will be executed to save one book into DynamoDB.

sh script/publish_sns.sh
...
...
{
    "MessageId": "e78906f5-4544-5e19-9191-5e9ea2a859bd"
}

After executing this command, please check your DynamoDB. You can find a new item in that.

For Async Batch Request, execute the following command, which will upload a json file(script/input_s3.json) into S3 and finally the lambda functions will be executed to save a large of books into DynamoDB.

sh script/upload_s3.sh
...
...
upload: script/input_s3.json to s3://serverlesscdkdemo-serverlessstack-us-east-2-75157/batch/input_s3.json

After executing this command, please check your DynamoDB. You can find the multiple items in that.

For Sync Single Request, execute the following command, which will send http-get request and finally the lambda functions will be executed to get a list of books in DynamoDB.

sh script/request_api.sh
...
...
{
  "status": "success",
  "books": [
    {
      "isbn": "isbn-01",
      "src": "sns",
      "title": "book-01"
    },
    {
      "isbn": "isbn-03",
      "src": "s3",
      "title": "book-03"
    },
    {
      "isbn": "isbn-02",
      "src": "s3",
      "title": "book-02"
    },
    {
      "isbn": "isbn-04",
      "src": "s3",
      "title": "book-04"
    }
  ]
}

About CDK-Project

The cdk.json file tells the CDK Toolkit how to execute your app.

And the more usuful CDK commands are

  • cdk list list up CloudFormation Stacks
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk synth emits the synthesized CloudFormation template
  • cdk destroy remove resources

How to clean up

Execute the following command, which will destroy all resources except S3 Buckets and DynamoDB Tables. So destroy these resources in AWS web console manually.

sh script/destroy_stacks.sh

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

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].