Skip to content

Instantly share code, notes, and snippets.

@yogyrahmawan
Created May 5, 2023 01:58
Show Gist options
  • Save yogyrahmawan/6ac47002d26db1fb9b9f5b79998780e1 to your computer and use it in GitHub Desktop.
Save yogyrahmawan/6ac47002d26db1fb9b9f5b79998780e1 to your computer and use it in GitHub Desktop.
sst sqs subscription
import { Stack, App } from '@serverless-stack/resources';
import { Function } from '@serverless-stack/resources/aws';
import { SqsSubscription } from '@serverless-stack/resources/aws/sqs';
export default function main(app: App) {
const stack = new Stack(app, 'my-stack');
// Create an SQS queue
const myQueue = stack.addQueue('MyQueue');
// Create a Lambda function
const myFunction = new Function(stack, 'MyFunction', {
handler: 'src/myFunction.handler',
});
// Subscribe the Lambda function to the SQS queue
new SqsSubscription(stack, 'MySubscription', {
queue: myQueue,
handler: myFunction,
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment