Here are the cloudformation templates to setup an authentication mechanism for your API using AWS cognito and AWS API Gateway
Please deploy the AWS-Cognito.yml first, as the integration.yml has a dependency on it. Also, manually deploy these changes to the API Gateway stages.