Skip to content

create and deploy a serverless application with AWS CDK in 10 mins

Notifications You must be signed in to change notification settings

bobbyquennell/serverless-the-cdk-way

Repository files navigation

serverless-with-cdk

create and deploy a simple serverless application within 10 mins

Infrastructure Tree

we organize infra into a tree - the construct tree, which will make our infra resources "loosely coupled" between services and make them easy to maintain and read.

Composition is the killer feature of IAC

  • reusable components can implement best practices and share it within an organisation/team/company, or publicly
  • higher-level abstractions are composed from many lower-level constructs, and those lower-level constructs can be composed from even lower-level constructs #iac-composition

3 Layers of the tree

  • App is the root of the tree, a top layer construct which represents the entire application.
  • the APP is a container of one or more Stacks. Each stack represents a deployable Cloudformation Stack template. A stack defines a collection of AWS resources that you can manage as a single unit:(create, update, delete)
  • Constructs L0-3 are the basic building blocks of AWS CDK apps. Most often used constructs are Level2 and Level3
graph TD
    App[App] --> s1
    App --> s2
    subgraph CDK Constructs
        s2r1[lambda function]
    end
    subgraph CDK Constructs
        s1r1[event bus]
        s1r2[event bus log group]
    end
    subgraph CDK Stacks
        s1(Stack 1: shared Infra)
        s2(Stack 2: service A)
    end
    s1 --> s1r1
    s1 --> s1r2
    s2 --> s2r1
Loading

note:

Development and Deploy

  1. if you run CDK deploy locally, modify the .env.local to set the target account and region explicitly

  2. run cdk diff before you deploy to AWS this cmd will output the difference between the already deployed CloudFormation template and the CloudFormation template equivalent of our current CDK code.

  3. if you are happy the result from cdk diff, run cdk deploy to deploy the resources

Since this app includes more than a single stack, specify which stacks to use (wildcards are supported) or specify --all

About

create and deploy a serverless application with AWS CDK in 10 mins

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published