aws-api-gateway

AWS API Gateway - How do I get the date/timestamp/epoch in a body mapping template?

故事扮演 提交于 2019-12-04 10:50:20
I need to include the request time in the body mapping template for an API Gateway method. Is there a date/time variable or function? I couldn't find anything in the template reference . Example body mapping template: Action=SendMessage&MessageBody=$util.urlEncode("{""timestamp"":""TIMESTAMP_HERE"",""body-json"":$input.json('$'),""params"":""$input.params()""}") UPDATE: API Gateway just added two new context variables http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html $context.requestTime The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss

When does API Gateway validate revoked Cognito ID token

允我心安 提交于 2019-12-04 08:37:28
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); Are admin calls such as cognitoIdentityServiceProvider.globalSignOut and cognitoIdentityServiceProvider

Enable CORS when using AWS API Gateway Request Validator

假装没事ソ 提交于 2019-12-04 08:16:15
I setup AWS API Gateway with CORS successfully, when a request is valid I have a 200 status code and also CORS headers, that's nice. But when AWS API Gateway Request Validator detects an invalid input, I have the status code is 400 but CORS headers are not sent... That's really unfortunate, because the client sees a CORS errors instead of a real 400 error (for exemple with fetch the client is not able to distinguish 400 errors because of CORS errors). This question may be related to Get detailed error messages from AWS API Gateway Request Validator I came to this answer through a discussion

Handling different end points for AWS API Gateway Stages

那年仲夏 提交于 2019-12-04 05:59:06
I want to be able to change my end point defined in each API Gateway method so that a staging environment called "Dev" points to my internal Dev API and Prod stage of course would route to my Production API. Right now I'd have to manually change each method and then deploy to the prod stag but now to do any testing I'd have to change them all back again for a dev stage. I am moving ahead with a DNS switch to move Dev to Prod but future development still requires a change on every method. example: I have a resource called User and a GET Method which maps to an end point (HTTP Proxy) -> http:/

Exporting api definition from AWS API Gateway

无人久伴 提交于 2019-12-04 05:36:34
I'm creating an entire API in AWS API Gateway. Since I'm using the graphical console, just because I'm in a learning phase, I will need some way to create the same API programmatically or via the CLI. Is there some facilities to do export the current API set in some way I can reproduce the same structure? I've just published a tool for exporting existing APIs from Amazon API Gateway: Amazon API Gateway Swagger Exporter https://github.com/isabinin/aws-apigateway-swagger-exporter Hopefully you'll find it useful. this feature is now available via CLI directly from Amazon. It produces the same

How to enable “ApiKeyRequired” property in SAM without explicit swagger definition?

廉价感情. 提交于 2019-12-04 04:43:06
问题 In cloudformation, AWS::ApiGateway::Method has a boolean property ApiKeyRequired . How can i achieve the same in SAM ? I know that we can enable using explicit swagger Configuration. which is like this { "swagger": "2.0", "info": { "version": "1.0", "title": { "Ref": "AWS::StackName" } }, "x-amazon-apigateway-api-key-source": "HEADER", "paths": { "/": { "get": { "x-amazon-apigateway-integration": { "httpMethod": "POST", "type": "aws_proxy", "uri": { "Fn::Sub": "arn:aws:apigateway:${AWS:

Serverless framework v1 - multiple resources in one service

限于喜欢 提交于 2019-12-04 04:42:57
问题 I have two resources, games and players, both have crud functions. Are these supposed to be in the same serverless service? I would like to separate them, but how do I then put them in the same api gateway? 回答1: A serverless framework projects deploys a single API Gateway. So if you want it to be in different API Gateways you need separate serverless framework projects. Depending on the size of the services you are making it can make sense or it might not. To merge the two API Gateways higher

How can I send multiple Set-Cookie headers from API Gateway using a proxied Lambda

被刻印的时光 ゝ 提交于 2019-12-04 03:28:44
问题 I'm using API Gateway's Proxy integration to call a Lambda. The output format specification is this follow JSON format: { "statusCode": httpStatusCode, "headers": { "headerName": "headerValue", ... }, "body": "..." } In one response I wish to set two cookies (two different auth cookies) but JSON doesn't allow having two identical keys in the headers object (OK, technically the spec does but most libraries do not). RFC 7230 notes that Set-Cookie should be handled specially but I can't see how

How to create an AWS Lambda/API gateway python function that takes a pdf file as input using multipart/form-data?

我只是一个虾纸丫 提交于 2019-12-03 21:10:39
I have been struggling with this for a while now. I need to create a resource in API gateway linking to a lambda function that takes a pdf file as input sent as a multipart/form-data POST request. To make it simple, I am just returning the file for now. When I try to call the API with the following curl, I get Internal server error from AWS. Did anyone ever succeeded to send a pdf file to Lambda without having to use the S3 trick (upload to S3)? Thank you all in advance for any hint. Commands/Files: curl curl -vvv -X POST -H "Content-Type: multipart/form-data" -F "content=@file.pdf" https://..

Limit access to lambda or api gateway to a specific vpc

十年热恋 提交于 2019-12-03 16:21:56
is it possible to make an api gateway or lambda function accessible only by a specific vpc. I searched in amazon doc, but I didn't find anything about this subject. Thank you in advance Unfortunately, you won't be able to do that (See update below). s3 is the service which provides that kind of control access through Bucket policies . What you can do is grant permissions to your callers (Lambda invoker and API caller) . Take a look at these resources: Control Access to an API with IAM Permissions Control Access for Invoking an API Overview of Managing Access Permissions to Your AWS Lambda