aws-api-gateway

custom authorizers in Amazon API Gateway 500 error

孤街醉人 提交于 2019-12-01 05:41:46
I use Serverless-Authentication-boilerplate and want to map custom error response. But it always return 500 error. authorize.js // Authorize function authorize(event, callback) { let providerConfig = config(event); try { let data = utils.readToken(event.authorizationToken, providerConfig.token_secret); console.log("Decrypted data: " + JSON.stringify(data)); let methodArn = event.methodArn.replace(/(GET|POST|PUT|DELETE)/g, '*').replace(/mgnt.+/g, 'mgnt/*'); console.log(`Change methodArn to: ${methodArn}`); // TODO: handle expiration time validation callback(null, utils.generatePolicy( data.id,

AWS API Gateway MTLS client auth

故事扮演 提交于 2019-12-01 05:39:11
Everytime I searched for Mutual Auth over SSL for AWS API Gateway I can only find MTLS between AWS API Gateway and Backend Services. But I'm looking to secure my AWS API Gateway endpoints itself with MTLS (client auth) . For instance, I have a backed service QueryCustomer which I have proxied through AWS API Gateway. Now I can put an SSL Cert on API Gateway but it's usual 1-way SSL. What I want to achieve is to have an MTLS with client auth where the consumer of APIs from AWS API Gateway first have to exchange their public certificates which we configure on the AWS truststores and AWS public

AWS Lambda C# - Accessing custom context

拥有回忆 提交于 2019-12-01 04:33:43
问题 I have a simple Lambda function written in .NET Core (C#) that uses the APIGatewayProxyRequest object to go through all the request properties. If I test this lambda function (from AWS Lambda), and pass it a sample event config that contains basic information: I can get this information like so: public string FunctionHandler(APIGatewayProxyRequest request, ILambdaContext context) logger.Logger.Log($"Body: {request.Body} \n"); logger.Logger.Log($"Path: {request.Path} \n"); logger.Logger.Log($

AWS API Gateway Custom Authorizer AuthorizerConfigurationException

本秂侑毒 提交于 2019-12-01 03:45:59
For a Kinesis stream, I created a proxy API using AWS API Gateway. I added a custom authorizer using python Lambda for the proxy. After publish of lambda function and deploy of API, I was able to successfully test the API using Gateway Test functionality. I could see the logs in cloudwatch which had detailed prints from custom auth lambda function. After successful authentication, API Gateway pushed the record to my Kinesis stream However when I call the same API from Chrome Postman client, I get 500 Internal Server Error and response headers includes X-Cache → Error from cloudfront, x-amzn

How to pass cognito user information to lambda?

你说的曾经没有我的故事 提交于 2019-12-01 03:43:42
I'm developing application based on API Gateway and Lambda. I configured POST /subscribe as "AWS_IAM". So now it cannot accessible directly, but I can access to API with Cognito authentication. Now problem is my Lambda doesn't know who is the API caller. How to know that? I have 2 users: "Bob" and "John". My Lambda need to know that caller is Bob or John. Thanks, Scott Willeke You can get the Cognito Identity ID from the identity property of the context parameter ( context.identity ) as explained in the context Object Properties section of the Lambda Programming Model help topic . Once you

AWS API Gateway error response generates 502 “Bad Gateway”

删除回忆录丶 提交于 2019-12-01 03:05:57
问题 I have an API Gateway with a LAMBDA_PROXY Integration Request Type. Upon calling context.succeed in the Lambda, the response header is sent back with code 302 as expected (shown below). However, I want to handle 500 and 404 errors, and the only thing I am sure about so far, is that I am returning the error incorrectly as I am getting 502 Bad Gateway . What is wrong with my context.fail ? Here is my handler.js const handler = (event, context) => { //event consists of hard coded values right

AWS API Gateway MTLS client auth

て烟熏妆下的殇ゞ 提交于 2019-12-01 01:51:55
问题 Everytime I searched for Mutual Auth over SSL for AWS API Gateway I can only find MTLS between AWS API Gateway and Backend Services. But I'm looking to secure my AWS API Gateway endpoints itself with MTLS (client auth) . For instance, I have a backed service QueryCustomer which I have proxied through AWS API Gateway. Now I can put an SSL Cert on API Gateway but it's usual 1-way SSL. What I want to achieve is to have an MTLS with client auth where the consumer of APIs from AWS API Gateway

AWS API Gateway with Step Function

喜夏-厌秋 提交于 2019-12-01 00:45:51
I want a sample to integrate AWS API Gateway with Step Function. I have read this tutorial Creating a Step Functions API Using API Gateway but that tutorial needs me to send request in format of { "input": "{}", "name": "PostmanExecution", "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:Custom" } I want to send normal request and configure this stateMachineArn in API Gateway only, so that clients dont need to send this. Create your API Gateway resource and method. Then in the "Method Execution" settings, in the Integration Request, use these settings: Integration type:

Returning binary body and http headers from an AWS lambda through API gateway

假装没事ソ 提交于 2019-12-01 00:19:33
I have a lambda that needs to return a binary object and some http headers (e.g. content-type) through an api gateway (using lambda integration) OR redirect to another URL. In the binary support examples (e.g. https://aws.amazon.com/blogs/compute/binary-support-for-api-integrations-with-amazon-api-gateway/ ) the lambda only returns the (base64 of the) binary object (the image). In my case, I also need to return a status code and http headers (or something equivalent). I struggle with how I can make this work with binary support in api gateway. The lambda returns a json on this form: {

Invoke AWS Lambda and return response to API Gateway asyncronously

妖精的绣舞 提交于 2019-11-30 23:04:57
My use case is such that I'll have an AWS Lambda front ended with API Gateway. My requirement is that once the Lambda is invoked it should return a 200 OK response back to API Gateway which get forwards this to the caller. And then the Lambda should start its actual processing of the payload. The reason for this is that the API Gateway caller service expects a response within 10 seconds else it times out. So I want to give the response before I start with the processing. Is this possible? With API Gateway's "Lambda Function" integration type, you can't do this with a single Lambda function --