jacob-meacham / serverless-plugin-bind-deployment-id

:link: Serverless plugin to bind the randomly generated deployment id to custom resources
MIT License
33 stars 7 forks source link

Question: Just use one stage? #16

Closed tobilg closed 10 months ago

tobilg commented 4 years ago

Thanks for your work on this plugin! I have a question, is it possible to just use one stage? I see that if I stick to the example, a stage named __unused_stage__ is created additionally to my already existing stage dev.

I'd really prefer if it'd be possible to just have one, and to be honest I didn't really get the explanation under https://www.npmjs.com/package/serverless-plugin-bind-deployment-id#known-issues Could you eventually clarify this a bit? Thanks a lot in advance!

tobilg commented 4 years ago

As a follow up, I just tried doing this:

Resources:
  ApiGatewayAccessLogGroup:
      Type: AWS::Logs::LogGroup
      Properties:
        LogGroupName: ${self:custom.apiGateway.accessLogGroupName}
        RetentionInDays: ${self:custom.apiGateway.accessLogRetentionInDays}
  __deployment__:
    Properties:
      Description: The API Gateway deployment
      StageName: ${self:provider.stage}
  ApiGatewayStage:
    Type: 'AWS::ApiGateway::Stage'
    Properties:
      DeploymentId:
        Ref: __deployment__
      RestApiId:
        Ref: ApiGatewayRestApi
      StageName: ${self:provider.stage}
      TracingEnabled: false
      MethodSettings:
        - HttpMethod: '*'
          ResourcePath: '/*'
          LoggingLevel: INFO
          MetricsEnabled: true
          DataTraceEnabled: false
      AccessLogSetting:
        Format: '{"apiId":"$context.apiId","stage":"$context.stage","resourcePath":"$context.resourcePath","requestId":"$context.requestId","awsEndpointRequestId":"$context.awsEndpointRequestId","xrayTraceId":"$context.xrayTraceId","requestTime":"$context.requestTime","requestTimeEpoch":$context.requestTimeEpoch,"httpMethod":"$context.httpMethod","status":"$context.status","path":"$context.path"}'
        DestinationArn: '#{ApiGatewayAccessLogGroup.Arn}'

and this seems to work so that only one stage is created. Is this fine from your perspective?

jacob-meacham commented 4 years ago

Hey @tobilg it's possible that Serverless has fixed the issue that required the `__unused_stage__`` workaround - what version of Serverless are you using?

tobilg commented 4 years ago

I‘m using 1.52.2 currently

jacob-meacham commented 4 years ago

It took me a while to take a look, but it appears from a bit of testing that this is indeed fixed from the Serverless side. If you haven't noticed any other gotchas and want to open a PR for changing the documentation, that would be great. Thanks!