Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provisioned concurrency is not working with SQS lambda event #8249

Closed
grozdz opened this issue Sep 15, 2020 · 4 comments · Fixed by #8298
Closed

Provisioned concurrency is not working with SQS lambda event #8249

grozdz opened this issue Sep 15, 2020 · 4 comments · Fixed by #8298

Comments

@grozdz
Copy link

grozdz commented Sep 15, 2020

Hello,

There is an issue while deploying Lambda function with provisionedConcurrency enabled which uses SQS as event source. The error message is following:

An error occurred: LambdaEventSourceMappingSQSqueue - Invalid request provided: Function does not exist (Service: Lambda, Status Code: 400, Request ID: 2774b672-c894-4a5a-b478-79d2230ad64e, Extended Request ID: null).

It seems that SLS is not injecting DependsOn for Event Source Mapping into CFN template which expects alias to be present while creating this event source mapping (here template generated):

"LambdaEventSourceMappingSQSqueue": {
      "Type": "AWS::Lambda::EventSourceMapping",
      "DependsOn": [],
      "Properties": {
        "BatchSize": 10,
        "EventSourceArn": "arn:aws:sqs:XXXXX:XXXXXXXXXX:lambda",
        "FunctionName": {
          "Fn::Join": [
            ":",
            [
              {
                "Fn::GetAtt": [
                  "LambdaLambdaFunction",
                  "Arn"
                ]
              },
              "provisioned"
            ]
          ]
        },
        "Enabled": true
      }
    },

If I deploy Lambda with events section commented but with provisionedConcurrency enabled, and after that I uncomment events section and redeploy - it works fine. So my conclusion is, that there is missing dependency for provisioned alias that is expected for CFN. The error message Function does not exist is confusing, but it apparently means that alias provisioned is not yet created. I think that might be related to this: #8059.

serverless.yml
lambda:
  name: lambda
  handler: handler.execute
  role: arn:aws:iam::XXXXXXXXXXX:role/lambda
  provisionedConcurrency: 2
  events:
    - sqs: arn:aws:sqs:XXXXXXX:XXXXXXXXXXX:queue
serverless deploy --stage dev --config serverless.yml --conceal output
Serverless Error ---------------------------------------
 
  An error occurred: LambdaEventSourceMappingSQSqueue - Invalid request provided: Function does not exist (Service: Lambda, Status Code: 400, Request ID: 2774b672-c894-4a5a-b478-79d2230ad64e, Extended Request ID: null).
 

Installed version

Framework Core: 1.83.0 (local)
Plugin: 3.8.4
SDK: 2.3.2
Components: 2.34.9
@medikoo
Copy link
Contributor

medikoo commented Sep 15, 2020

@grozdz great thanks for openning that. Indeed it's likely that alias needs to be added, in same manner as it's done here:

const { targetAlias } = this.serverless.service.functions[functionName];
if (targetAlias) {
albInvokePermission.DependsOn = [targetAlias.logicalId];
}

PR with a fix is welcome!

@radove
Copy link

radove commented Sep 24, 2020

We had issues where Provisioned Concurrency would not get setup for an API Gateway in our automatic build environment that uses the latest serverless version. We had to roll back to an older version to get our Provisioned Concurrency to work again via serverless. I don't have too much time or expertise at the moment to track down the bug like @medikoo @grozdz did, but wanted to report this.

@medikoo
Copy link
Contributor

medikoo commented Sep 24, 2020

@radove if you have a scenario where provisioned concurrency setup worked with older Framework version, and it's not working with latest version, if possible please open new bug report with all the details

AFAIK This report describes case where provisioned concurrency never worked (when it was introduced, it didn't come with necessary changes to SQS event)

@pgrzesik
Copy link
Contributor

I'm happy to pick this one up 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants