DEV Community

Marcos Henrique
Marcos Henrique

Posted on

11 2

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




Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

AWS GenAI LIVE!

GenAI LIVE! is a dynamic live-streamed show exploring how AWS and our partners are helping organizations unlock real value with generative AI.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️