Tim
Tim

Reputation: 374

How to override AWS Amplify's authorizer in API Gateway

When I create a new API category resource I want to automatically create a Cognoto User Pool authorizer.

I discovered that I can customize the response headers on my api with the below snippet but can't figure out how to use this to configure an authorizer.

// This file is used to override the REST API resources configuration
import { AmplifyApiRestResourceStackTemplate } from '@aws-amplify/cli-extensibility-helper';

export function override(resources: AmplifyApiRestResourceStackTemplate) {
  resources.restApi.body.paths['/storage/{proxy+}'].options['x-amazon-apigateway-integration'].responses.default.responseParameters['method.response.header.Access-Control-Allow-Headers'] = "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,x-aspera-cache-control'";
}

My current workaround is to manually create and assign one to my endpoint, but it's not ideal.

How do you create this Cognito User Pool Authorizer resource via the Amplify CLI?

Upvotes: 0

Views: 857

Answers (1)

Gowtham
Gowtham

Reputation: 614

At the moment, Amplify CLI doesn't support congnito-authorizer for API-gateway:api created, but can be achieved by using overrides .

Ref: https://docs.amplify.aws/cli/restapi/override/

Upvotes: 1

Related Questions