<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Frank Wang</title>
    <description>The latest articles on DEV Community by Frank Wang (@fwang).</description>
    <link>https://dev.to/fwang</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F186138%2F59f54086-fd9f-4baf-b47f-4e81aea79985.jpeg</url>
      <title>DEV Community: Frank Wang</title>
      <link>https://dev.to/fwang</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fwang"/>
    <language>en</language>
    <item>
      <title>Work on your Lambda functions live</title>
      <dc:creator>Frank Wang</dc:creator>
      <pubDate>Tue, 26 Jan 2021 15:32:57 +0000</pubDate>
      <link>https://dev.to/aws-builders/work-on-your-lambda-functions-live-51cp</link>
      <guid>https://dev.to/aws-builders/work-on-your-lambda-functions-live-51cp</guid>
      <description>&lt;p&gt;&lt;a href="https://aws.amazon.com/cdk/" rel="noopener noreferrer"&gt;AWS CDK&lt;/a&gt; has been great for us and our readers over on &lt;a href="https://serverless-stack.com" rel="noopener noreferrer"&gt;Serverless Stack&lt;/a&gt;. But the local development experience for Lambda isn't great. To fix this we created a &lt;strong&gt;Live Lambda Development&lt;/strong&gt; environment in &lt;a href="https://github.com/serverless-stack/serverless-stack" rel="noopener noreferrer"&gt;SST&lt;/a&gt;. SST makes it easier to build serverless apps by allowing you to work on your Lambda functions locally while connecting to your deployed resources.&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/hnTSTm5n11g"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Before we look at how it works, let's look at what the local development environment for serverless is usually like.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Working on Lambda functions locally can be painful. You have to either:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Locally mock all the services that your Lambda function uses&lt;/p&gt;

&lt;p&gt;Like API Gateway, SNS, SQS, etc. This is hard to do. If you are using a tool that mocks a specific service (like API Gateway), you won't be able to test a Lambda that's invoked by a different service (like SNS). On the other hand a service like LocalStack, that tries to mock a whole suite of services, is slow and the mocked services can be out of date.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Or, you'll need to deploy your changes to test them&lt;/p&gt;

&lt;p&gt;Each deployment can take at least a minute. And repeatedly deploying to test a change really slows down the feedback loop.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Introducing &lt;code&gt;sst start&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;To fix this we added the &lt;code&gt;sst start&lt;/code&gt; command to the &lt;a href="https://github.com/serverless-stack/serverless-stack" rel="noopener noreferrer"&gt;Serverless Stack Toolkit (SST)&lt;/a&gt;. It's an extension to AWS CDK that makes it easier to build serverless apps using CDK.&lt;/p&gt;

&lt;p&gt;This command does a couple of things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It deploys a debug stack with a WebSocket API to the same AWS account and region as your app.&lt;/li&gt;
&lt;li&gt;It deploys your app and replaces the Lambda functions with a stub Lambda.&lt;/li&gt;
&lt;li&gt;Starts up a local WebSocket client to connect to the debug stack.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The debug stack contains a serverless WebSocket API and a DynamoDB table. The stub Lambda when invoked, sends a message to the WebSocket API, which in turn sends a message to the local client connected to it. The client then executes the local version of the Lambda function and sends back the results to the WebSocket API. Which then responds to the stub Lambda. And finally the stub Lambda responds back with the results.&lt;/p&gt;

&lt;h2&gt;
  
  
  An Example
&lt;/h2&gt;

&lt;p&gt;Let's look at an example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdocs.serverless-stack.com%2Fimg%2Fsst-start-demo-architecture.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdocs.serverless-stack.com%2Fimg%2Fsst-start-demo-architecture.png" alt=" sst-start-architecture "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this sample app we have:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;An API Gateway endpoint&lt;/li&gt;
&lt;li&gt;An SNS topic&lt;/li&gt;
&lt;li&gt;A Lambda function (api.js) that responds to the API and sends a message to the SNS topic&lt;/li&gt;
&lt;li&gt;A Lambda function (sns.js) that subscribes to the SNS topic&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So when a request is made to the API endpoint, the stub version of api.js gets invoked and sends a message to the debug stack. This in turn gets streamed to the client. The client invokes the local version of api.js and returns the results to the debug stack. The local version also sends a message to the SNS topic. Meanwhile, the stub api.js responds to the API request with the results. Now the stub version of sns.js gets invoked as it is subscribed to the SNS topic. This gets sent to the debug stack which in turn gets streamed to the client to execute the local version of sns.js. The results of this are streamed back to stub sns.js that responds with the results.&lt;/p&gt;

&lt;p&gt;You can &lt;a href="https://github.com/serverless-stack/sst-start-demo" rel="noopener noreferrer"&gt;try out this sample repo here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages
&lt;/h2&gt;

&lt;p&gt;This approach has a couple of advantages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can work on your Lambda functions locally&lt;/li&gt;
&lt;li&gt;While interacting with your entire deployed AWS infrastructure&lt;/li&gt;
&lt;li&gt;It supports all Lambda triggers, so there's no need to mock API Gateway, SQS, SNS, etc.&lt;/li&gt;
&lt;li&gt;It supports real Lambda environment variables&lt;/li&gt;
&lt;li&gt;And Lambda IAM permissions, so if a Lambda fails on AWS due to the lack of IAM permissions, it would fail locally as well.&lt;/li&gt;
&lt;li&gt;And it's fast! There's nothing to deploy when you make a change!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A couple of things to note.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The debug stack is completely serverless

&lt;ul&gt;
&lt;li&gt;So you don't get charged when it's not in use&lt;/li&gt;
&lt;li&gt;And it's very cheap per request, it'll be within the free tier limits&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;All the data stays between your local machine and your AWS account

&lt;ul&gt;
&lt;li&gt;There are no 3rd party services that are used&lt;/li&gt;
&lt;li&gt;Support for connecting to AWS resources inside VPC is coming soon&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;sst start&lt;/code&gt; command in &lt;a href="https://github.com/serverless-stack/serverless-stack" rel="noopener noreferrer"&gt;&lt;strong&gt;SST&lt;/strong&gt;&lt;/a&gt; creates a live lambda development environment. By extending AWS CDK, it allows you to build serverless applications in CDK while having a first-class local development environment.&lt;/p&gt;

&lt;p&gt;As one of our early users put it; &lt;em&gt;&lt;code&gt;sst start&lt;/code&gt; is the future of Lambda development&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you like the SST project, consider &lt;strong&gt;starring our repo&lt;/strong&gt; — &lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/sst" rel="noopener noreferrer"&gt;
        sst
      &lt;/a&gt; / &lt;a href="https://github.com/sst/sst" rel="noopener noreferrer"&gt;
        sst
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      SST v2
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;
  &lt;a href="https://sst.dev/" rel="nofollow noopener noreferrer"&gt;
    &lt;img alt="SST" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fsst%2Fidentity%2Fmain%2Fvariants%2Fsst-full.svg" width="300"&gt;
  &lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;
   &lt;a href="https://sst.dev/discord" rel="nofollow noopener noreferrer"&gt;&lt;img alt="Discord" src="https://camo.githubusercontent.com/27038c1e0a90dd08c1380a46c54247ec2ef8f51fe1d11f41c0aa75fe7bd99091/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3938333836353637333635363730353032353f7374796c653d666c61742d737175617265266c6162656c3d446973636f7264"&gt;&lt;/a&gt;
  &lt;a href="https://www.npmjs.com/package/sst" rel="nofollow noopener noreferrer"&gt;&lt;img alt="npm" src="https://camo.githubusercontent.com/af83c9d45d16f100fe878cdff30ef1241bd4933f24d8789239388c0451595e52/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f7373742e7376673f7374796c653d666c61742d737175617265"&gt;&lt;/a&gt;
  &lt;a href="https://github.com/sst/sst/actions/workflows/test.yml" rel="noopener noreferrer"&gt;&lt;img alt="Build status" src="https://camo.githubusercontent.com/cb9eb33f63d8d4fe378b4d24febc038c1bdf603a69d07b41f2cd506730643995/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7373742f7373742f746573742e796d6c3f7374796c653d666c61742d737175617265266272616e63683d6d6173746572"&gt;&lt;/a&gt;
&lt;/p&gt;




&lt;p&gt;SST makes it easy to build modern full-stack applications on AWS. Watch the &lt;a href="https://youtu.be/JY_d0vf-rfw" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;SST in 100 seconds&lt;/strong&gt;&lt;/a&gt; video to learn more.&lt;/p&gt;

&lt;div class="highlight highlight-source-shell notranslate position-relative overflow-auto js-code-highlight"&gt;
&lt;pre&gt;$ npx create-sst@latest&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;For v2 docs, head over to &lt;a href="https://v2.sst.dev" rel="nofollow noopener noreferrer"&gt;v2.sst.dev&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Pick your frontend&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;Deploy Next.js, Svelte, Remix, Astro, Solid, or any static site to AWS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.sst.dev/start/nextjs" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;Next.js&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.sst.dev/start/svelte" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;Svelte&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.sst.dev/start/remix" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;Remix&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.sst.dev/start/astro" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;Astro&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.sst.dev/start/solid" rel="nofollow noopener noreferrer"&gt;&lt;strong&gt;Solid&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Add any feature&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;SST gives you the full power of AWS. Making it easy to add any feature to your product.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.sst.dev/file-uploads" rel="nofollow noopener noreferrer"&gt;File uploads&lt;/a&gt; — Allow your users to upload files to S3.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.sst.dev/auth" rel="nofollow noopener noreferrer"&gt;Auth&lt;/a&gt; — Authenticate your users through any auth provider.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.sst.dev/events" rel="nofollow noopener noreferrer"&gt;Events&lt;/a&gt; — Run tasks after your app has returned to your user.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.sst.dev/databases" rel="nofollow noopener noreferrer"&gt;Databases&lt;/a&gt; — Use a serverless SQL or NoSQL database to power your app.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.sst.dev/cron-jobs" rel="nofollow noopener noreferrer"&gt;Jobs&lt;/a&gt; — Run cron jobs or long running jobs powered by serverless functions.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.sst.dev/apis" rel="nofollow noopener noreferrer"&gt;APIs&lt;/a&gt; — Add a dedicated serverless REST, GraphQL, or WebSocket API to your app.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="markdown-heading"&gt;
&lt;h3 class="heading-element"&gt;Collaborate with your team&lt;/h3&gt;
&lt;/div&gt;

&lt;p&gt;Finally, you…&lt;/p&gt;
&lt;/div&gt;


&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/sst/sst" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


</description>
      <category>aws</category>
      <category>cdk</category>
      <category>serverless</category>
      <category>sst</category>
    </item>
    <item>
      <title>Using Serverless Framework and CDK together</title>
      <dc:creator>Frank Wang</dc:creator>
      <pubDate>Wed, 16 Sep 2020 02:31:12 +0000</pubDate>
      <link>https://dev.to/aws-builders/using-serverless-framework-and-cdk-together-12he</link>
      <guid>https://dev.to/aws-builders/using-serverless-framework-and-cdk-together-12he</guid>
      <description>&lt;p&gt;While helping folks work through our &lt;a href="https://serverless-stack.com" rel="noopener noreferrer"&gt;Serverless Stack guide&lt;/a&gt;, we noticed that most folks have a really hard time using CloudFormation templates to define their AWS infrastructure. And so it's no surprise that we are really excited about &lt;a href="https://aws.amazon.com/cdk/" rel="noopener noreferrer"&gt;AWS CDK&lt;/a&gt;! It allows you to define any AWS infrastructure using modern programming languages. Making CDK, truly &lt;em&gt;infrastructure as code&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/serverless/serverless" rel="noopener noreferrer"&gt;Serverless Framework&lt;/a&gt; on the other hand is great for building Serverless applications on AWS. While you can build Serverless apps purely with CDK, it doesn't have a great developer experience. On the flip side, Serverless Framework allows you to deploy any non-Serverless AWS infrastructure. But it requires you to use CloudFormation templates written in YAML or JSON.&lt;/p&gt;

&lt;p&gt;The overlap between these two frameworks have &lt;a href="https://blog.codecentric.de/en/2019/09/aws-cdk-versus-terraform-and-serverless-framework/" rel="noopener noreferrer"&gt;led folks to write&lt;/a&gt; about &lt;a href="https://www.secjuice.com/aws-cdk-vs-serverless-framework/" rel="noopener noreferrer"&gt;why you should use one versus the other&lt;/a&gt;. However, we think they are meant to be used together, in tandem. And we've created a tool to do so — &lt;a href="https://github.com/serverless-stack/serverless-stack" rel="noopener noreferrer"&gt;&lt;strong&gt;Serverless Stack Toolkit&lt;/strong&gt;&lt;/a&gt; (SST). Allowing you to get the best of both worlds!&lt;/p&gt;

&lt;p&gt;Let's look at this in detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;Before we dive in, let's quickly get some background on these frameworks.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Serverless Framework
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/serverless/serverless" rel="noopener noreferrer"&gt;Serverless Framework&lt;/a&gt; was released back in October 2015. It allows you to develop Serverless applications locally and deploy them with ease. It's driven by a &lt;code&gt;serverless.yml&lt;/code&gt; config file that looks something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;service&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;serverless-example&lt;/span&gt;

&lt;span class="na"&gt;provider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;aws&lt;/span&gt;
  &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nodejs12.x&lt;/span&gt;

&lt;span class="na"&gt;functions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;handler.hello&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can invoke your Lambda functions locally using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;serverless invoke &lt;span class="nb"&gt;local&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And deploy them by:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;serverless deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Serverless Framework will automatically package your Lambda functions and upload them to AWS.&lt;/p&gt;

&lt;p&gt;You can also add other AWS infrastructure using CloudFormation templates in YAML. For example, you can add a DynamoDB table using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Resources&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;NotesTable&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AWS::DynamoDB::Table&lt;/span&gt;
    &lt;span class="na"&gt;Properties&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;TableName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${self:custom.tableName}&lt;/span&gt;
      &lt;span class="na"&gt;AttributeDefinitions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;AttributeName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;userId&lt;/span&gt;
          &lt;span class="na"&gt;AttributeType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;S&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;AttributeName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;noteId&lt;/span&gt;
          &lt;span class="na"&gt;AttributeType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;S&lt;/span&gt;
      &lt;span class="na"&gt;KeySchema&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;AttributeName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;userId&lt;/span&gt;
          &lt;span class="na"&gt;KeyType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HASH&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;AttributeName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;noteId&lt;/span&gt;
          &lt;span class="na"&gt;KeyType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;RANGE&lt;/span&gt;
      &lt;span class="na"&gt;BillingMode&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PAY_PER_REQUEST&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What is AWS CDK
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/cdk/" rel="noopener noreferrer"&gt;AWS CDK&lt;/a&gt; (Cloud Development Kit) was &lt;a href="https://aws.amazon.com/blogs/developer/aws-cdk-developer-preview/" rel="noopener noreferrer"&gt;released in Developer Preview back in August 2018&lt;/a&gt;. It allows you to use TypeScript, JavaScript, Java, .NET, and Python to create AWS infrastructure.&lt;/p&gt;

&lt;p&gt;So for example, here is how a CloudFormation template for a DynamoDB table would compare to the CDK version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;- Resources:
-   NotesTable:
-     Type: AWS::DynamoDB::Table
-     Properties:
-       TableName: ${self:custom.tableName}
-       AttributeDefinitions:
-         - AttributeName: userId
-           AttributeType: S
-         - AttributeName: noteId
-           AttributeType: S
-       KeySchema:
-         - AttributeName: userId
-           KeyType: HASH
-         - AttributeName: noteId
-           KeyType: RANGE
-       BillingMode: PAY_PER_REQUEST
&lt;/span&gt;&lt;span class="err"&gt;

&lt;/span&gt;&lt;span class="gi"&gt;+ const table = new dynamodb.Table(this, "notes", {
+   partitionKey: {
+     name: 'userId', type: dynamodb.AttributeType.STRING,
+   },
+   sortKey: {
+     name: 'noteId', type: dynamodb.AttributeType.STRING,
+   },
+   billingMode: dynamodb.BillingMode.PAY_PER_REQUEST,
+ });
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also allows you to create higher order constructs. This means that you can combine and compose lower level resources to create new reusable constructs.&lt;/p&gt;

&lt;p&gt;Similar to Serverless Framework, you can deploy a CDK app using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;cdk deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It also allows you to define Lambda functions as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;helloSrc&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;handler.js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;helloLambda&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;HelloLambda&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;runtime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Runtime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NODEJS_12_X&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;handler&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;handler.hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;InlineCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;helloSrc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utf-8&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, it doesn't offer a great local development experience for your Lambda functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Serverless Framework and CDK together
&lt;/h2&gt;

&lt;p&gt;To recap, here's how Serverless Framework and CDK compare.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Serverless Framework&lt;/th&gt;
&lt;th&gt;AWS CDK&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Perfect for Lambda functions&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;td&gt;〰️&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Perfect for other infrastructure&lt;/td&gt;
&lt;td&gt;〰️&lt;/td&gt;
&lt;td&gt;✅&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So if you are building a Serverless application that includes other AWS infrastructure, it would make a ton of sense to use Serverless Framework for your Lambda functions and CDK for the rest.&lt;/p&gt;

&lt;p&gt;As an aside, a similar design pattern of splitting up your Lambda functions from the other infrastructure is common in the Serverless community and &lt;a href="https://serverless-stack.com/chapters/organizing-serverless-projects.html" rel="noopener noreferrer"&gt;we recommend it over on Serverless Stack&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;However, there are a couple of design differences between the two that you need to be wary of.&lt;/p&gt;

&lt;h3&gt;
  
  
  Design differences between Serverless Framework and CDK
&lt;/h3&gt;

&lt;p&gt;Serverless apps are made up of multiple services and the app as a whole is deployed to the same environment.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fznu2tsb62b9294btev5f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fznu2tsb62b9294btev5f.png" alt="Deploy Serverless Framework app to single environment"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Each service is deployed as a CloudFormation stack to the target AWS account. You can specify a stage, region, and AWS profile to customize this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="nv"&gt;$ AWS_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;development serverless deploy &lt;span class="nt"&gt;--stage&lt;/span&gt; dev &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--stage&lt;/code&gt; option here prefixes your stack names with the stage name. So if you are deploying multiple stages to the same AWS account, the resource names will not thrash.&lt;/p&gt;

&lt;p&gt;This allows you to easily deploy your Serverless app to multiple environments. Even if they are in the same AWS account.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Figq2gi7jf278i7rh1o7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Figq2gi7jf278i7rh1o7a.png" alt="Deploy Serverless Framework app to multiple environments"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWS CDK apps on the other hand are made up of multiple stacks. And each stack is deployed to the target AWS account as a CloudFormation stack. However, unlike Serverless apps, each stack can be deployed to a different AWS account or region.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh9gudpzvd0bypl08a2gp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fh9gudpzvd0bypl08a2gp.png" alt="Deploy CDK app to multiple environments"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This means that each time you deploy your CDK app, it could potentially create a stack in multiple environments. This critical design difference prevents us from using CDK apps alongside our Serverless services.&lt;/p&gt;

&lt;p&gt;You can fix this issue by following a certain convention in your CDK app, as outlined in this post — &lt;a href="https://dev.to/miensol/deploy-aws-cdk-app-to-different-environments-297d"&gt;Deploy aws-cdk app to different environments&lt;/a&gt;. However, this is only effective if these conventions are enforced.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enter, Serverless Stack Toolkit
&lt;/h2&gt;

&lt;p&gt;To fix this, we created the &lt;a href="https://github.com/serverless-stack/serverless-stack" rel="noopener noreferrer"&gt;&lt;strong&gt;Serverless Stack Toolkit&lt;/strong&gt;&lt;/a&gt; (SST).&lt;/p&gt;

&lt;p&gt;SST allows you to follow the same conventions as Serverless Framework. This means that you can deploy your Lambda functions using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ AWS_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production serverless deploy &lt;span class="nt"&gt;--stage&lt;/span&gt; prod &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And use CDK for the rest of your AWS infrastructure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ AWS_PROFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;production npx sst deploy &lt;span class="nt"&gt;--stage&lt;/span&gt; prod &lt;span class="nt"&gt;--region&lt;/span&gt; us-east-1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just like Serverless Framework, the stacks in your CDK app are prefixed with the stage name. Now you can use Serverless Framework and CDK together! Allowing you to do something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fijkzzx5bitlsj90de70e.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fijkzzx5bitlsj90de70e.jpeg" alt="Deploy Serverless Framework with CDK using SST"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that, if you define the AWS account or region as a part of your CDK stack, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MyStack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;my-stack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;account&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1234&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;us-east-1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You'll get an error.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Do not directly set the environment for a stack
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  And there's more!
&lt;/h3&gt;

&lt;p&gt;SST also has a couple of other key advantages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Concurrent deployments&lt;/p&gt;

&lt;p&gt;AWS CDK deployments are currently very slow. CDK deploys your CloudFormation stacks in sequence. It'll submit a CloudFormation template for deployment and wait till it completes, before starting the next one. This means that CDK deployments for large apps can easily take at least half an hour. SST fixes this by deploying your CloudFormation stacks concurrently.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Asynchronous deployments&lt;/p&gt;

&lt;p&gt;SST also supports deploying your CloudFormation stacks asynchronously. So you don't have to waste CI build minutes waiting for CloudFormation to complete. &lt;a href="https://seed.run/blog/sst-deployments-beta" rel="noopener noreferrer"&gt;Seed natively supports concurrent asynchronous deployments for your SST apps.&lt;/a&gt; Making it nearly 5 times faster and virtually free to deploy!&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports ES6 (and TypeScript) out-of-the-box&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Automatically lints your CDK code using ESLint&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Differences between SST and CDK
&lt;/h3&gt;

&lt;p&gt;SST is a simple extension of CDK with a couple of minor differences.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;There is no &lt;code&gt;cdk.json&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Instead there is a &lt;code&gt;sst.json&lt;/code&gt; with the defaults for your stage and region.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"my-sst-app"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"@serverless-stack/resources"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"stage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dev"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"region"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"us-east-1"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;There is no &lt;code&gt;bin/*.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Instead there is a &lt;code&gt;lib/index.js&lt;/code&gt; that has a default export function where you can add your stacks. Note that, SST creates the App object for you.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;MyStack&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./MyStack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MyStack&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;my-stack&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Add more stacks&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Stacks extend &lt;code&gt;sst.Stack&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Your stack classes extend &lt;code&gt;sst.Stack&lt;/code&gt; instead of &lt;code&gt;cdk.Stack&lt;/code&gt;. This allows SST to prefix your stack names with the stage you are deploying to.&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;sst&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;@serverless-stack/resources&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyStack&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;sst&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Stack&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can read more about &lt;a href="https://github.com/serverless-stack/serverless-stack#migrating-from-cdk" rel="noopener noreferrer"&gt;moving a CDK app to SST here&lt;/a&gt;. So if you'd like to use SST but have an existing CDK app, you can do so by following a couple of easy steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;We think &lt;a href="https://aws.amazon.com/cdk/" rel="noopener noreferrer"&gt;AWS CDK&lt;/a&gt; is a vast improvement over CloudFormation templates that are written in YAML or JSON. And the combination of &lt;a href="https://github.com/serverless/serverless" rel="noopener noreferrer"&gt;Serverless Framework&lt;/a&gt; and CDK allows you to leverage the best of both worlds. Develop and deploy Lambda functions using Serverless Framework and define the rest of your AWS infrastructure with CDK. To make sure that you can use the two together, we created the &lt;strong&gt;&lt;a href="https://github.com/serverless-stack/serverless-stack" rel="noopener noreferrer"&gt;Serverless Stack Toolkit&lt;/a&gt;&lt;/strong&gt; (SST). A simple extension of CDK that allows you to deploy CDK apps alongside your Serverless Framework services!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cdk</category>
      <category>serverless</category>
      <category>sst</category>
    </item>
  </channel>
</rss>
