Skip to content

OpenApiGatewayToLambda - Dynamically inclue ARN for Cognito Pool Authorizer #1330

@StephenGoodall

Description

@StephenGoodall

Is there a way to dynamically include the ARN in the providerArns when using the "x-amazon-apigateway-authorizer" in the open API document?

I've created the cognito pool/scopes/domain/client etc. in CDK, but I just realised nothing is showing in the UI for API Gateway, so I don't think it is linked up to the gateway. I used an example that seemed to setup cognito pool as a standard oauth provider rather than anything AWS specific.

I saw the example here that showed the cognito pool in the provider ARN list, but it required a hard-coded ARN.

It's very possible I'm just doing something wrong in my current code which is causing it to not get attached.
Switching to the example in the repo does seem like a much more straightforward option, if it's possible to dynamically add that ARN value somehow as I'd be deploying to multiple accounts/environments so they'd each have a different ARN for the cognito pool.

components:
  securitySchemes:
    UserPool:
      type: oauth2
      description: Using Cognito oAuth
      x-amazon-apigateway-authorizer: 
        type: jwt 
        identitySource: "$request.header.Authorization" # This indicates that the JWT token is passed in the Authorization header of the request
        jwtConfiguration:
          audience:
            - "XXXXXXXXXXXXXXXXXXXXXXXXXX" # This is where you specify the client ID of your Cognito user pool app client
          issuer: https://cognito-idp.XX-XXXXXXX-X.amazonaws.com/XX-XXXXXXX-X_xxxxxxxx

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions