8

Create SQS + DLQ with aws-cdk v2 on typescript

 2 years ago
source link: https://dev.to/wakeupmh/create-sqs-dlq-with-aws-cdk-v2-on-typescript-4djh
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

giphy.gif%3Fcid%3Decf05e47ibb2jj8ckpd704juf7vyxrlxmv5m9pjyh98t5k8c%26rid%3Dgiphy.gif%26ct%3Dg

Our stack is:

  • aws-cdk v2
  • typescript ### Instalations
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:

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

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

all cdk labs goes here dude xD


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK