Hi,
I want to create a lambda function and that the lambda function uses Sqs. But I would like to create a Queue with serverless.yml. I read two articles about creation of Queue and I am a little bit confused.
And here is my serverless.yml with local-stack
#To run locally
service: neighborhood-like
plugins:
-serverless-localstack
custom :
localstack:
host: http://localhost
stages:
- local
stages:
- local
- prod
provider:
name: aws
runtime: dotnetcore2.1
region: ${opt:region, 'eu-central-1'}
stage: ${opt:stage, 'local'}
iamRoleStatements:
- Effect: Allow
Action:
- sqs:*
Resource:
Fn::GetAtt: [ NewSQSQueue, Arn ]
package:
individually: true
functions:
functionHandler:
handler: NeighborhoodLikeConsumer.Lambda::NeighborhoodLikeConsumer.Lambda.Function::FunctionHandler
environment:
ASPNETCORE_ENVIRONMENT: ${env:ASPNETCORE_ENVIRONMENT}
events:
- schedule: cron(*/2 * * * ? *)
package:
artifact: artifact/neighborhood-like.zip
resources:
Resources:
NewSQSQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: sqs-queue-${opt:stage, self:provider.stage}.fifo
FifoQueue: true
or should I use
service: neighborhood-like
plugins:
- serverless-plugin-lambda-dead-letter
provider:
name: aws
memorySize: ****
runtime: dotnetcore2.1
region: eu-central-1
deploymentBucket:
name: ****
functions:
functionHandler:
handler: NeighborhoodLikeConsumer.Lambda:NeighborhoodLikeConsumer.Lambda.Function::FunctionHandler
environment:
ASPNETCORE_ENVIRONMENT: ${env:RUNTIME_ENVIRONMENT}
events:
- schedule: cron(* * * * ? *)
deadLetter:
targetArn:
GetResourceArn: LikeDLQueue
package:
artifact: artifacts/neighborhood-like/${env:IMAGE_TAG}/neighborhood-like.zip
resources:
Resources:
LikeQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: LikeQueue${env:RUNTIME_ENVIRONMENT}.fifo
FifoQueue: true
RedrivePolicy:
deadLetterTargetArn:
Fn::GetAtt:
- "LikeDLQueue"
- "Arn"
maxReceiveCount: 1
LikeDLQueue:
Type: "AWS::SQS::Queue"
Properties:
QueueName: LikeDLQueue${env:RUNTIME_ENVIRONMENT}.fifo
FifoQueue: true
LikeDLQueuePolicy:
Type: AWS::SQS::QueuePolicy
Properties:
Queues:
- Ref: LikeDLQueue