aws-api-gateway

Getting json body in aws Lambda via API gateway

别说谁变了你拦得住时间么 提交于 2019-12-17 15:42:24
问题 I'm currently using NodeJS to build a bot on AWS lambda via AWS Api Gateway and I'm running into an issue with POST requests and JSON data. My api uses 'Use Lambda Proxy integration' and even when I test the proxy sending a content-type of Application/json and some json in the body e.g {"foo":"bar"} I can't access the object without parsing it first e.g var json = JSON.parse(event.body); console.log(json.foo); Now I know this doesn't seem a big deal just running it through JSON.parse, but I

API Gateway - Post multipart\form-data

倾然丶 夕夏残阳落幕 提交于 2019-12-17 05:05:10
问题 Seems my question maybe a little similar to this one. I have an API within my API Gateway and am doing a HTTP proxy through to an endpoint that POST's multipart/form-data files. If I call the http endpoint directly (not through the API gateway) - using postman, it works as expected, however, using the API gateway endpoint (through postman) fails. I have compared both requests (through fiddler and CloudWatch logs) which seem to be identical: Request for direct API call (working): POST https:/

Is there a way to change the http status codes returned by Amazon API Gateway?

南笙酒味 提交于 2019-12-17 02:27:34
问题 For instance if I want to return a specific 400 error for invalid parameters or perhaps a 201 when the lambda function call resulted in a create. I'd like to have different http status codes but it looks like api gateway always returns a 200 status code even if the lambda function is returning an error. 回答1: Update per 20-9-2016 Amazon finally made this easy using the Lambda Proxy integration. This allows your Lambda function to return proper HTTP codes and headers: let response = {

Unable to execute Lambda in Async mode via API Gateway POST request

扶醉桌前 提交于 2019-12-14 03:53:47
问题 Why currently there no way to execute AWS Lambda in asynchronous mode via Gateway API without involving intermediary Lambda just for calling invoke() method? Even if i add integration like this: r = client.put_integration( restApiId=rest_api_id, resourceId=resource_id, httpMethod='POST', type='AWS', integrationHttpMethod='POST', uri=uri, requestParameters={ 'integration.request.header.X-Amz-Invocation-Type': "'Event'", 'integration.request.header.Invocation-Type': "'Event'" } ) It still

aws-amplify api.get federateInfo with options undefined error

邮差的信 提交于 2019-12-14 01:31:39
问题 I am playing around with aws-amplify and react-native. I am trying to make an api.get call on my home screen but keep running into the error: Get item: key is federatedInfo with options undefined I am calling an aws-api-gateway dynamodb. I have been looking at fixes with docs but most point to using HOC withAuthenticator. I don't want to do this since i've custom built signIn/signUP/Confirm screens. Any help or just a point in the right direction would be great. Here is my Home.screen code:

Execution failed due to configuration error: Invalid permissions on Lambda function

荒凉一梦 提交于 2019-12-13 16:06:22
问题 I am building a serverless application using AWS Lambda and API Gateway via Visual Studio. I am working in C#, and using the serverless application model (SAM) in order to deploy my API. I build the code in Visual Studio, then deploy via publish to Lambda. This is working, except every time I do a new build, and try to execute an API call, I get this error: Execution failed due to configuration error: Invalid permissions on Lambda function Doing some research, I found this fix mentioned

AWS Lambda de-serializer / LinkedHashmap cannot cast

a 夏天 提交于 2019-12-13 15:19:09
问题 I'm new to Java/AWS etc., and AWS lambda we not de-serialize what I think is a trivial example. The API Gateway log, which is sending JSON to my lambda: Execution log for request test-request Mon Sep 11 18:04:06 UTC 2017 : Starting execution for request: test-invoke-request Mon Sep 11 18:04:06 UTC 2017 : HTTP Method: POST, Resource Path: / Mon Sep 11 18:04:06 UTC 2017 : Method request path: {} Mon Sep 11 18:04:06 UTC 2017 : Method request query string: {} Mon Sep 11 18:04:06 UTC 2017 : Method

What's the correct way of returning HTTP error codes in serverless lambda

北城以北 提交于 2019-12-13 14:45:08
问题 I have a serverless lambda function written in Node.JS. What is the best / correct way of returning error codes? The pattern that I use right now ( and it works! ) is: module.exports.endpoint = (event, context, callback) => { const response = { statusCode: 404, body: JSON.stringify({ message: 'Hello World!' }) }; callback(null, response); } When I make a call, for example from POSTMAN, to my endpoint I get: Status: 404 Not Found which is exactly what I'm expecting . Moreover, in the logs I

AWS API Gatewat with proxy Lambda: Invalid permissions on Lambda function

こ雲淡風輕ζ 提交于 2019-12-13 14:01:54
问题 I am using AWS API Gateway with a proxy Lambda, when the name of the lambda function is coming as a stage variable. Meaning I have a single API integration which connects to appropriate lambda according to the deployed stage. See the general idea here: When I test one of my stages (called: "staging") everything works fine, but when testing the other stage ("production") I get the error "Execution failed due to configuration error: Invalid permissions on Lambda function". Things I already

Accessing AWS API Gateway from an EC2 using IAM authorization (NodeJS)

浪子不回头ぞ 提交于 2019-12-13 12:35:06
问题 Perhaps I'm going a bridge to far here but heres what I got: An AWS API Gateway Method that has AWS_IAM set for Authorization. A Policy that allows access to that Method. An EC2 Role that has that policy attached to it. An EC2 Launched with that Role. I would like to have my NodeJS program (or any language for that matter) on that EC2 to be able to call that API without hardcoding an AccessKey and SecretKey in the code. I have used this approach to use the aws-sdk to put/get records on S3,