Trying to deploy an SQS queue with a lambda worker in typescript. Deployment crashed with Resource handler returned message: "An event source mapping with SQS arn (" arn:aws:sqs:eu-west-1:<account id>:media-converter-dev-convert ") and function (" media-converter-dev-convertWorker ") already exists. Please update or delete the existing mapping with UUID <uuid> error.
$ sls deploy --verbose
Running "serverless" from node_modules
Deploying media-converter to stage dev (eu-west-1)
Packaging
Compiling to node18 bundle with esbuild...
Compiling with concurrency: 10
Compiling completed.
Zip function: convertWorker - 794.20 KB [125 ms]
Retrieving CloudFormation stack
Uploading
Uploading CloudFormation file to S3
Uploading State file to S3
Uploading service convertWorker.zip file to S3 (813.26 kB)
Updating CloudFormation stack
Creating new change set
Waiting for new change set to be created
Change Set did not reach desired state, retrying
Executing created change set
UPDATE_IN_PROGRESS - AWS::CloudFormation::Stack - media-converter-dev
CREATE_IN_PROGRESS - AWS::SQS::Queue - convertDlqDB521409
CREATE_IN_PROGRESS - AWS::Logs::LogGroup - ConvertWorkerLogGroup
CREATE_IN_PROGRESS - AWS::SQS::Queue - convertDlqDB521409
CREATE_IN_PROGRESS - AWS::Logs::LogGroup - ConvertWorkerLogGroup
CREATE_COMPLETE - AWS::Logs::LogGroup - ConvertWorkerLogGroup
CREATE_COMPLETE - AWS::SQS::Queue - convertDlqDB521409
CREATE_IN_PROGRESS - AWS::SQS::Queue - convertQueue5B730BC5
CREATE_IN_PROGRESS - AWS::SQS::Queue - convertQueue5B730BC5
CREATE_COMPLETE - AWS::SQS::Queue - convertQueue5B730BC5
CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CREATE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
CREATE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution
CREATE_IN_PROGRESS - AWS::Lambda::Function - ConvertWorkerLambdaFunction
CREATE_IN_PROGRESS - AWS::Lambda::Function - ConvertWorkerLambdaFunction
CREATE_COMPLETE - AWS::Lambda::Function - ConvertWorkerLambdaFunction
CREATE_IN_PROGRESS - AWS::Lambda::Version - ConvertWorkerLambdaVersionqIk0mHczKiAKClRLqeYRHzUIuvRVx3MsATRq8itMIl0
CREATE_IN_PROGRESS - AWS::Lambda::Version - ConvertWorkerLambdaVersionqIk0mHczKiAKClRLqeYRHzUIuvRVx3MsATRq8itMIl0
CREATE_COMPLETE - AWS::Lambda::Version - ConvertWorkerLambdaVersionqIk0mHczKiAKClRLqeYRHzUIuvRVx3MsATRq8itMIl0
CREATE_IN_PROGRESS - AWS::Lambda::EventSourceMapping - ConvertWorkerEventSourceMappingSQSConvertQueue5B730BC5
CREATE_FAILED - AWS::Lambda::EventSourceMapping - ConvertWorkerEventSourceMappingSQSConvertQueue5B730BC5
UPDATE_ROLLBACK_IN_PROGRESS - AWS::CloudFormation::Stack - media-converter-dev
UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS - AWS::CloudFormation::Stack - media-converter-dev
DELETE_SKIPPED - AWS::Lambda::Version - ConvertWorkerLambdaVersionqIk0mHczKiAKClRLqeYRHzUIuvRVx3MsATRq8itMIl0
DELETE_COMPLETE - AWS::Lambda::EventSourceMapping - ConvertWorkerEventSourceMappingSQSConvertQueue5B730BC5
DELETE_IN_PROGRESS - AWS::Lambda::Function - ConvertWorkerLambdaFunction
DELETE_COMPLETE - AWS::Lambda::Function - ConvertWorkerLambdaFunction
DELETE_IN_PROGRESS - AWS::IAM::Role - IamRoleLambdaExecution
DELETE_IN_PROGRESS - AWS::Logs::LogGroup - ConvertWorkerLogGroup
DELETE_COMPLETE - AWS::Logs::LogGroup - ConvertWorkerLogGroup
DELETE_COMPLETE - AWS::IAM::Role - IamRoleLambdaExecution
DELETE_IN_PROGRESS - AWS::SQS::Queue - convertQueue5B730BC5
DELETE_COMPLETE - AWS::SQS::Queue - convertQueue5B730BC5
DELETE_IN_PROGRESS - AWS::SQS::Queue - convertDlqDB521409
DELETE_COMPLETE - AWS::SQS::Queue - convertDlqDB521409
UPDATE_ROLLBACK_COMPLETE - AWS::CloudFormation::Stack - media-converter-dev
✖ Stack media-converter-dev failed to deploy (480s)
Environment: linux, node 18.12.1, framework 3.27.0 (local) 3.26.0v (global), plugin 6.2.3, SDK 4.3.2
Credentials: Local, "personal-ok" profile
Docs: docs.serverless.com
Support: forum.serverless.com
Bugs: github.com/serverless/serverless/issues
Error:
CREATE_FAILED: ConvertWorkerEventSourceMappingSQSConvertQueue5B730BC5 (AWS::Lambda::EventSourceMapping)
Resource handler returned message: "An event source mapping with SQS arn (" arn:aws:sqs:eu-west-1:<account id>:media-converter-dev-convert ") and function (" media-converter-dev-convertWorker ") already exists. Please update or delete the existing mapping with UUID <uuid> (Service: Lambda, Status Code: 409, Request ID: <request id>)" (RequestToken: <request token>, HandlerErrorCode: AlreadyExists)
View the full error: <link>
It looks like the issue is due to the lambda and SQS queue being created simultaneously and triggering a race condition. The issue on serverless side point to a possible resolution by adding a dependsOn to make sure the lambda is created first.
Description
Trying to deploy an SQS queue with a lambda worker in typescript. Deployment crashed with
Resource handler returned message: "An event source mapping with SQS arn (" arn:aws:sqs:eu-west-1:<account id>:media-converter-dev-convert ") and function (" media-converter-dev-convertWorker ") already exists. Please update or delete the existing mapping with UUID <uuid>
error.How to Reproduce
Additional Information
It looks like the issue is due to the lambda and SQS queue being created simultaneously and triggering a race condition. The issue on serverless side point to a possible resolution by adding a
dependsOn
to make sure the lambda is created first.