Is it possible to spin up infrastructure such as a SQS queue in front of a Lambda function using AWS SAM without a API gateway?
I only see options to sam local invoke "Lambda" -e event.json
and sam local start-api
When I run my lambda which is trying to read messages from the message queue it is not finding the Message Queue URL as referenced below:
NotificationFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
Handler: index.handler
Runtime: nodejs8.10
Role: !Sub ${ConsumerLambdaRole.Arn}
Timeout: 10
Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
Variables:
NODE_ENV: 'dev'
MANDRILL_API_KEY: 'PUyIU3DAxJzIlt7KbBE5ow'
SQS_URL: !Ref MessageQueue
MessageQueue:
Type: AWS::SQS::Queue
Properties:
VisibilityTimeout: 60
RedrivePolicy:
deadLetterTargetArn: !Sub ${DeadLetterQueue.Arn}
maxReceiveCount: 10
# this is where any failed messages will go to
DeadLetterQueue:
Type: AWS::SQS::Queue
sam local
only spins up the lambda part of the sam specification. The rest has to be connected manually by spinning up dockers, checkingAWS_SAM_LOCAL
to change endpoints in the code etc. – fiddur