Skip to content

AWS API Gateway stages are deployed as different API instances (no AWS stages are used) #2445

Closed

Description

@mtomic

This is a (Bug Report)

Description

I'm not sure if this is by design, but one of the major differences between deploying 0.5.6 serverless functions and v1 is that AWS API Gateway names are prefixed with stage. AWS recommend creating generic API Gateway names, with multiple stages inside it. Image below shows how v1 deployment works:
screen shot 2016-10-19 at 11 05 59 am

0.5.6 version would deploy it within a single API, but have multiple stages inside it. This feels more correct, see below:
screen shot 2016-10-19 at 11 16 07 am

Is there a way to achieve this structure with v1?

Similarly, Lambda functions aren't versioned and Aliased the way they were in 0.5.6. Currently all function names are prefixed with a stage, which creates a large number of lambda functions. Is there a way to achieve function aliasing in the deploy process so that the API gateway references the correctly aliased function by setting the correct stage Variable like this:
screen shot 2016-10-19 at 11 20 31 am

screen shot 2016-10-19 at 11 22 07 am

Activity

  1. hereandnow commented on Oct 20, 2016

    @hereandnow

    I wanted to open excactly the same Issue. APIG has the concept of Stages, we really should use that!

    i tried to overwrite the name in the serverless.yml file:

    resources:
     Resources:
       ApiGatewayRestApi:
         Type: AWS::ApiGateway::RestApi
           Properties:
             Name: my-service-name
    

    didnt work. the cloudformation-template-create-stack.json created has that name:

    {
      "ApiGatewayRestApi": {
        "Type": "AWS::ApiGateway::RestApi",
        "Properties": {
          "Name": "my-service-name"
        }
      }
    }
    

    the cloudformation-template-update-stack.json not ;-(

    {
      "ApiGatewayRestApi": {
        "Type": "AWS::ApiGateway::RestApi",
        "Properties": {
          "Name": "develop-my-service-name"
        }
      }
    }
    

    at least that workaround should do!

  2. leonardoalifraco commented on Nov 1, 2016

    @leonardoalifraco

    This is happening to me too. Is this by design?

  3. andymac4182 commented on Nov 1, 2016

    @andymac4182
    Contributor

    This is by design. @leonardoalifraco

    Due to the way that Cloudformation works and a lot of businesses that have multiple accounts for each environment so single API Gateway per stage allows for deploying and removing independently of each other. Also API Gateway is the only service that supports stages.

  4. leonardoalifraco commented on Nov 1, 2016

    @leonardoalifraco

    Makes sense. Thanks!

  5. andymac4182 commented on Nov 2, 2016

    @andymac4182
    Contributor

    @dashmug Is there anything else I can cover to help explain this?

  6. dashmug commented on Nov 2, 2016

    @dashmug
    Contributor

    @andymac4182
    I'm sure you guys have thought this through but it's not very clear to me yet.

    What's the problem with the way serverless v0.5.6 does it (using API Gateway's "Stages") versus version 1's one-stage, one-gateway approach?

  7. 31 remaining items

  8. removed their assignment
    on Dec 20, 2019
  9. michelem09 commented on Mar 19, 2020

    @michelem09

    So we are on 2020 and this issue is still open, is there a way to have every stages under the same API?
    Thanks

  10. cldsnchz commented on May 30, 2020

    @cldsnchz

    Sorry if this is off-topic but I guess it is somehow related.

    Currently the provider stage is also used to configure the APIG stage name
    Is there any way to customize the APIG stage name?, something like having:

    provider:
      apiGateway:
        stageName: xxxxxxxxxx
    

    I would like to configure the stages dev, test, etc but all of them with v1 as APIG stage name, but I haven't found a way to do that.

  11. tomaszdudek7 commented on Aug 3, 2020

    @tomaszdudek7

    @michelem09 Duh, we're closer to 2021 now.

    @cldsnchz (How) did you solve it? It has been a few months. :)

  12. medikoo commented on Aug 19, 2020

    @medikoo
    Contributor

    Closing, for reasons listed here: #2445 (comment)

    Still I believe stage and service tokens order in API name is indeed confusing, and doesn't seem right (not sure why it was decided to have {stage}-{service} instead of {service}-{stage} as in all other cases) for that issue please track #2918

  13. changed the title [-]AWS API Gateway stages and names are separated[/-] [+]AWS API Gateway stages are deployed as different API instances (no AWS stages are used)[/+] on Aug 19, 2020
  14. added
    wontfix
    on Aug 19, 2020
  15. sc0ttdav3y commented on Apr 28, 2021

    @sc0ttdav3y

    For those coming to this ticket in 2021 looking for answers, it looks like V3 of serverless will implement API gateway naming as ${service}-${stage} as many have asked for. You can adopt this now with a config setting.

    https://www.serverless.com/framework/docs/deprecations#api-gateway-naming-will-be-changed-to-service-stage

  16. medikoo commented on Apr 28, 2021

    @medikoo
    Contributor

    it looks like V3 of serverless will implement API gateway naming as ${service}-${stage} as many have asked for. You can adopt this now with a config setting.

    We actually decided to revert from that, as migration from already deployed API gateway requires API to be removed and re-created, and also we'd rather push users to migrate to HTTP API instead. Still the setting will remain working.

    Reference: #9160 (comment)

  17. sc0ttdav3y commented on Apr 28, 2021

    @sc0ttdav3y

    Thanks for the response @medikoo.

    I’m only 1 week in as a serverless dev, so here are my take-aways:

    • The shouldStartNameWithService setting works, will still be supported and gives me a consistent name that doesn’t grate my type-A personality 🎉
    • It’s not the preferred way to do it though.
    • There is a new httpAPI

    I didn’t know about httpAPI — all the getting started recipes and tutorials I’ve come across talk about http.

    Thanks again for following up.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    cat/aws-event-api-gatewaywontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions