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

Renaming a Serverless::Function used by an Api Gateway does not deploy the Gateway #634

Closed
jceloi opened this issue Oct 23, 2018 · 6 comments

Comments

@jceloi
Copy link

jceloi commented Oct 23, 2018

Description:

Only renaming (no code change) a Serverless::Function using a FunctionName property does not trigger an Api Gateway stage deploy and the API Gateway stage still points to the previous lambda, which in that case does not exist anymore, generating an internal server error.

Manually triggering an API Gateway deploy does solve the problem, but according to me that should be done automatically when the FunctionName changes.

Steps to reproduce the issue:

  1. Using cloudformation, create an AWS::Serverless::Api pointing at a AWS::Serverless::Function . Deploy it, check that the calls are correctly triggering the lambda.
  2. Add a static FunctionName property to the Function, different than the one previously generated during the first deploy. Redeploy the stack.
  3. Try to call the lambda through the api gateway again.

Observed result:

  • Error 500, Internal Server Error code
  • No event is routed to the lambda function

Expected result:

  • Correct invocation of the lambda function
@jvanbrunschot-coolblue
Copy link

We're running in the same issue. Renaming functions (without a code change) results in permission errors when invoking functions.
Execution failed due to configuration error: Invalid permissions on Lambda function

@brettstack
Copy link
Contributor

You should be able to change the logical resource id instead of setting FunctionName (which is best practice) and should trigger an API Gateway deploy. We have also discussed adding a new property to always deploy your API even if we can't detect a change to the API.

@keetonian
Copy link
Contributor

Closed in favor of #660

@eliottparis
Copy link

eliottparis commented Oct 30, 2019

You should be able to change the logical resource id instead of setting FunctionName (which is best practice) and should trigger an API Gateway deploy.

I'm facing the same issue here, but I need my FunctionName to be dynamically computed depending on an input template parameter.

Parameters:
  Stage:
    Type: String

Resources:
  MyFunction:
    Type: AWS::Serverless::Function
    Properties:
      FunctionName: !Join [ "", [ "MyFunction-", !Ref Stage]]

#660 could be an option in the future, but is there a way to achieve that for now?

@jlhood jlhood reopened this Oct 30, 2019
@jlhood
Copy link
Contributor

jlhood commented Oct 30, 2019

@eliottparis Sorry you're experiencing this. Reopening this issue since there's a more targeted change we could make to make FunctionName of any AWS::Serverless::Function resources with API events part of the hash input here:
https://github.com/awslabs/serverless-application-model/blob/dbc8f795fc42e997a6cf63cf8e2d01a9ccf6f040/samtranslator/model/apigateway.py#L97-L102

@jlhood
Copy link
Contributor

jlhood commented Oct 30, 2019

Actually, it looks like a draft PR had been put up to make this change, but wasn't completed. #1134

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

No branches or pull requests

7 participants