DEV Community

Marcos Henrique
Marcos Henrique

Posted on

Create SQS + DLQ with aws-cdk v2 on typescript

Let's suppose you want to create an asynchronous messaging application on aws, then you need to create a SQS and a DLQ to store your processing errors.

Queues can be great in scenarios where your application needs
something done but doesn’t need it done now, or doesn’t even care
about the result. Instead of calling a web service and waiting for it
to complete, you can write the message to a queue and let the same
business logic happen later.

It's show time

Our stack is:

  • aws-cdk v2
  • typescript ### Instalations ```bash

npm i -D @aws-cdk/assert ts-node ts-node-dev typescript aws-cdk
npm i aws-cdk-lib constructs

Before of all we need to bootstrap our project with the command bellow:
```bash


npx cdk bootstrap aws://ACCOUNT-NUMBER/REGION


Enter fullscreen mode Exit fullscreen mode

Bootstrapping is the deployment of a AWS CloudFormation template to a specific AWS environment (account and region). The bootstrapping template accepts parameters that customize some aspects of the bootstrapped resources (see Customizing bootstrapping).

Now you can create your Queue and DLQ following the example bellow:
code print

Create SQS is a piece of cake xD

If you want to see a real world project structure example, please take a look at the bottom of this post, is a link to my cdk repository with some examples

GitHub logo wakeupmh / cdk

all cdk labs goes here dude xD

cdk

all cdk labs goes here dude xD




Top comments (0)