aws-api-gateway

Amazon API Gateway IAM authenticated example with generated JS SDK

吃可爱长大的小学妹 提交于 2019-12-06 07:33:53
问题 I have created sample GET and POST APIs on Amazon API Gateway following their official documentation. I have generated JS SDK for these APIs, which I am using to call these APIs from a client-side JS file hosted on S3. This works flawlessly without any 'Authorization Type'. Now, when I set 'Authorization Type' for GET method as 'IAM', I am required to pass IAM credentials in order for it to work. In spite of passing my AWS account's root credentials, I am getting this in the response headers:

Return JSONP via AWS Lambda/API Gateway

这一生的挚爱 提交于 2019-12-06 07:33:36
问题 I'm trying to return jsonp as in callbackname(data.strified) callback( null, ( !!event.cb && event.cb.length > 0 ) ? event.cb.replace( /[^a-z0-9_]/i, '' ) + '(' + JSON.stringify( data ) + ')' : data ); My quick and dirty way now returns the data and if ?cb=test is given it returns: "test({\"valid\":false,\"data\":false})" Is there anyway to get rid of the quotes and escape characters? The API should work with and without callback set. 回答1: Given that you have this type of lambda function:

AWS ApiGateway Lambda Proxy access Authorizer

家住魔仙堡 提交于 2019-12-06 07:29:34
问题 I´m using an Lambda Proxy and a Cognito User Pool Authorizer in my ApiGateway. In the Lambda function I can access the path etc. variables via the event object. In addition to that I want to access the claims of the authenticated user. In the documentation it is written, that I should use: context.authorizer.claims.property But I authorizer is null so I get Cannot read property 'claims' of undefined Anyone with an idea? 回答1: If you are referring to this part of the documentation, $context

Can't use custom Request Headers on AWS API Gateway with CORS

扶醉桌前 提交于 2019-12-06 07:11:53
I have created and deployed an AWS API Gateway resource with the following structure including a custom HTTP Request Header 'X-header' dev (stage) /echo (resource) POST (method) Method Request - Headers: X-header OPTIONS (method) Method Request - Headers: X-header When I POST to the endpoint from Chrome, I get the following error. XMLHttpRequest cannot load https://fxxxx.execute-api.us-west-2.amazonaws.com/dev/echo . Request header field X-header is not allowed by Access-Control-Allow-Headers in preflight response. Chrome is doing a preflight check against the OPTIONS method. I can see the

Amazon API Gateway User keys

此生再无相见时 提交于 2019-12-06 06:34:39
I have an API deployed on AWS API Gateway. I will have multiple subscribers using my API and each customer would be unique. Is it possible that each customer will have a separate API key unique to him? Or will I have to create those many IAM users in order for them to be unique? If yes for the IAM users, then what is the upper limit of the number of users? I will be doing all this programmatically. By unique, if you mean that you should be able to identify which request came from who, then you can generate one API Key per subscriber. You can generate up to 10000 API keys per AWS account. More

HTTP request body not getting to AWS lambda function via AWS API Gateway

天大地大妈咪最大 提交于 2019-12-06 05:13:05
I have a very basic lambda function written in Scala deployed to AWS Lambda. The function works just fine when I test it via the AWS Lambda console. Here's the function with some additional logging added for debug purposes. package com.spacecorpshandbook.ostium.lambda.handler import java.util import com.google.gson.Gson import temp.{ApiGatewayProxyResponse, Appointment, CancelResponse} /** * Amazon Lambda handler adapter for the Cancellation application */ class CancellationHandler { def cancelAppointment(appointment: Appointment): ApiGatewayProxyResponse = { System.out.println("++++

AWS Lambda chaining best practice

半世苍凉 提交于 2019-12-06 03:45:19
I'm looking a solution for my problem and maybe someone could give me some ideas. I have a API Gateway plugged to a aws lambda A. I have to handle cases like this: Lambda A should call lambda B and if there are any results, return to the API Gateway. Lambda A should call lambda B and if no results, it will call lambda C, and then return whatever the results are to the APi Gateway . So, my problem is how to chain these lambdas, because I don't want to have a huge lambda. At first, I thought about using Step Functions except that this works in a asynchronous mode, so no good for my case. I know

When does API Gateway validate revoked Cognito ID token

僤鯓⒐⒋嵵緔 提交于 2019-12-06 03:24:43
问题 I am building a serverless react app which uses Cognito for sign-in/sign-out. The app calls API Gateway which is configured to use the Cognito User pool as the custom authorizer. I also build a lambda function to sign out a user ( cognitoIdentityServiceProvider.globalSignOut ). When I sign into the app, and then call the lambda function to perform an admin sign-out, calls to protected API gateway functions from the app are still valid (with Cognito ID token passed in Authorization header);

Api Gateway: AWS Subdomain for Lambda Integration

元气小坏坏 提交于 2019-12-06 02:27:05
I'm attempting to integrate my lambda function, which must run async because it takes too long, with API gateway. I believe I must, instead of choosing the "Lambda" integration type, choose "AWS Service" and specify Lambda. (e.g. this and this seem to imply that.) However, I get the message "AWS ARN for integration must contain path or action" when I attempt to set the AWS Subdomain to the ARN of my Lambda function. If I set the subdomain to just the name of my Lambda function, when attempting to deploy I get "AWS ARN for integration contains invalid path". What is the proper AWS Subdomain for

Can/will AWS API Gateway -> Lambda performance be improved?

南笙酒味 提交于 2019-12-06 01:54:27
问题 Has anyone found a solution to API Gateway latency issues? With a simple function testing API Gateway -> Lambda interaction, I regularly see cold starts in the 2.5s range, and once "warmed," response times in the 900ms - 1.1s range are typical. I understand the TLS handshake has its own overhead, but testing similar resources (AWS-based or general sites that I believe are not geo-distributed) from my location shows results that are half that, ~500ms. Is good news coming soon from AWS? (I've