aws-api-gateway

How to validate API Key in AWS Lambda function

孤者浪人 提交于 2019-12-25 01:47:03
问题 I have read quite a few articles like this one and it looks like currently in AWS API Gateway you cannot send API Key in query string. We also have few legacy clients that will need passing api-key in query string. So i thought of two options 1>Create lambda function as Integration Type and validate API in key inside function handler. But i am not able to figure out how to validate it against keys in aws. Something like public async Task<JObject> FunctionHandler(JObject request,

API Gatway proxy response when using ExclusiveStartKey

被刻印的时光 ゝ 提交于 2019-12-25 01:36:47
问题 Consider this example from docs for Amazon DynamoDB, here we have: dynamoDb.scan(params, onScan); function onScan(err, data) { if (err) { return; } else { collectedItems.push(data.Items); const response = { statusCode: 200, headers: { 'Access-Control-Allow-Origin': '*', }, body: JSON.stringify(collectedItems), }; callback(null, response); // continue scanning if we have more movies, because // scan can retrieve a maximum of 1MB of data if (typeof data.LastEvaluatedKey != "undefined") {

Cloudfront distribution does not enforce TLS settings for Gateway API

醉酒当歌 提交于 2019-12-25 00:46:52
问题 Follow up to AWS API Gateway should prevent use of TLS v1, I created a Cloudfront distribution with below config Origin Domain Name as my Gate API endpoint https://abcdfefg.execute-api.us-east-1.amazonaws.com Viewer Protocol Policy as HTTPS Only Origin SSL Protocols as TLSv1.2, TLSv1.1 (Unchecked TLSv1) other defaults After the distribution was deployed, when I access my Gateway API with custom domain, I still was able to make calls on TLSv1. How do I map my custom domain to this new

Response undefined - aws-api-gateway-client

我是研究僧i 提交于 2019-12-24 22:14:48
问题 I have created an AWS API Gateway to invoke a Lambda function to generate random numbers: Lambda Function : exports.handler = (event, context, callback) => { let min = parseInt(event.min); let max = parseInt(event.max); let generatedNumber = Math.floor(Math.random() * max) + min; context.done(null, {generatedNumber: generatedNumber}); }; Body mapping Template in API gateway for get method: { "min" : $input.params('min'), "max" : $input.params('max') } When I access API endpoint like below:

Lambda permissions error when setup using CloudFormation and API Gateway proxy

梦想的初衷 提交于 2019-12-24 20:49:32
问题 I am trying to write a cloudformation script that would create a lambda function and hook it up to the API Gateway proxy resource. Stack creation works, but there is something wrong with permissions or integration config, when I test the endpoint, I keep getting Mon Feb 12 06:45:28 UTC 2018 : Endpoint response body before transformations: Unable to determine service/operation name to be authorized Mon Feb 12 06:45:28 UTC 2018 : Endpoint response headers: {Connection=keep-alive, x-amzn

how to set timeout from frontend in apigClient aws

人盡茶涼 提交于 2019-12-24 20:32:17
问题 I'm working with the amazon api client gateway.it works fine with all the request and response. Now I want to add some timeout, I tried this: apigClient.method(params, body, additionalParams) .timeout(1000) .then(function (result) { //succcess part }).catch(function (err) { //error part });` But It doest work. I got this message from my console "error: apigClient.method(...).timeout is not a function" 回答1: The generated JS client doesn't support custom timeout by default, but you can add your

How to pass headers from AWS API Gateway

我怕爱的太早我们不能终老 提交于 2019-12-24 19:15:26
问题 I'm passing the addition key-value pairs from lambda function, same as mention in aws labs. Then in API Gateway I have setup the body mapping templates in integration request. (Check this). But when request goes to the endpoint (PHP) then I'm unable to get any data. It is empty array print_r($_REQUEST); I checked cloudWatch this is what it is showing. Endpoint request body after transformations: { "userData" : "{"city":"USA","Name":"Sanket","id":3}" } Additional info - When I print print_r($

Can't enable CORS on Lambda + API Gateway + Cloudfront on the Cloudfront layer

强颜欢笑 提交于 2019-12-24 18:33:55
问题 I have deployed a lambda, which in itself returns an 'Access-Control-Allow-Origin': '*' header in it's response. I call it from an API Gateway. When calling the API gateway URL, the CORS configuration is fine. I placed CloudFront in front of the API, however now I am unable to access the API as the CORS configuration seems to be overridden by CloudFront, and I am not sure where to add custom headers in CloudFront. How do you enable CORS inside CloudFront? 回答1: Go into your CloudFront

How to map querystring and header to AWS C# lambda function parameter

笑着哭i 提交于 2019-12-24 12:53:00
问题 I have AWS Gateway REST API that takes 2 querystring parameters https://xxxxxx.xxxx.us-east-1.amazonaws.com/dev/pets?type=dog&page=1 The caller of the API also include x-api-key in the header. I want API gateway to pass querystring parameters and x-api-key to lambda function. So in AWS API Gateway Console i have configured the Integration Request as below The lambda function looks like this namespace AWSLambda1 { public class Function { public string FunctionHandler(LambdaRequest request,

What Access-Control-* headers to send back in response to CORS preflight OPTIONS request and then subsequent GET/POST/etc. request?

浪尽此生 提交于 2019-12-24 12:23:03
问题 I'm setting up a custom authorization workflow on API Gateway and looking for insights on CORS. I have an authorizer that returns an IAM role based on validation of a barertoken - that then invokes the lambda my target endpoint which returns the response as desired. I've made this work by adding my barer token to both the OPTIONS method and the GET / POST methods. In general, I'm adding most CORS headers to the OPTIONS + GET / POST / etc methods, but this seems superfluous. I'm a little