Limiting aws authorizer to production deployment

I am using AWS_IAM authorizer for API Gateway endpoints.
Is it possible to bind the authorizer for production deployment only to make debugging during development easier?

testAuth:
    handler: handler.testAuth
    events:
    - http:
        path: test
        method: POST
        authorizer:
          type: aws_iam

It’s basically a variation on using different values for environment variables for each stage. You could follow that approach or start with something like this

custom:
  stage: "${opt:stage, self:provider.stage}"
  dev:
    authorizer:
  prod:
    authorizer:
        type: aws_iam

testAuth:
  events:
    - http:
        authorizer: ${self:custom.${self:custom.stage}.authorizer}

Note: I haven’t tested this so it might require some debugging

1 Like