aws-api-gateway

POST JSON object to aws lambda

落爺英雄遲暮 提交于 2019-12-22 04:43:25
问题 How can I post a json object to aws lambda function through aws API gateway ? p.s.- My goal is to write the lambda function in python and then post it to aws SQS. Thanks in advance. 回答1: I figured it out. Now I have a API Gateway acceptiong client posted JSON data of a specified format and then passing it to a AWS-Lambda function which, dumps the data into a AWS-SQS. The steps are explained below in details- STEP 1- Create a lambda function in any supported languages (I have used Python 3.6).

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

喜欢而已 提交于 2019-12-21 17:57:24
问题 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()""}") 回答1: UPDATE: API Gateway just added two new context variables http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway

Handling different end points for AWS API Gateway Stages

给你一囗甜甜゛ 提交于 2019-12-21 13:06:20
问题 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.

Is it possible to query an Amazon RDS instance directly from API Gateway?

瘦欲@ 提交于 2019-12-21 07:06:27
问题 I'm new to API Gateway, and as far I have tried is a really powerful tool. For the project I'm working right now we are using a PostgreSQL instance in RDS. I've seen that is possible to access directly to DynamoDB tables from API Gateway, so I was wondering if is there a way to do so for relational databases. So I created a resource with a GET method and configure it to connect to my database, but I wasn't sure if I used the right parameters: Provided information about the target backend So I

AWS Lambda Function is misinterpreting event dictionary in python?

心不动则不痛 提交于 2019-12-21 06:33:28
问题 I am trying to deploy a google calendar api to AWS Lambda. Since I was facing a problem in extracting the value from the event dictionary (created by lambda from the JSON payload of a POST request), i created a toy function to test def handler(event,context): a=event.get("type") if a=='create': return { "statusCode": 200, "headers": { "Content-Type": "text/plain"}, #"body": "Event_id"+ str(event_identifier) + " Event Link: " +str(links) "body" : str(a) } else: return { "statusCode": 200,

AWS Lambda Function is misinterpreting event dictionary in python?

点点圈 提交于 2019-12-21 06:33:07
问题 I am trying to deploy a google calendar api to AWS Lambda. Since I was facing a problem in extracting the value from the event dictionary (created by lambda from the JSON payload of a POST request), i created a toy function to test def handler(event,context): a=event.get("type") if a=='create': return { "statusCode": 200, "headers": { "Content-Type": "text/plain"}, #"body": "Event_id"+ str(event_identifier) + " Event Link: " +str(links) "body" : str(a) } else: return { "statusCode": 200,

How to call AWS API Gateway Endpoint with Cognito Id (+configuration)?

懵懂的女人 提交于 2019-12-21 04:10:17
问题 I want to call an AWS API Gateway Endpoint that is protected with AWS_IAM using the generated JavaScript API SDK . I have a Cognito UserPool and a Cognito Identity Pool . Both properly synced via ClientId . I use this code to Sign in and get the Cognito Identity AWS.config.region = 'us-east-1'; // Region AWS.config.credentials = new AWS.CognitoIdentityCredentials({ IdentityPoolId: 'us-east-1:XXXXXXXXXXXXXXXXXXXXXXXX' // your identity pool id here }); AWSCognito.config.region = 'us-east-1';

Mapping Lambda output in API Gateway gives server error

流过昼夜 提交于 2019-12-21 04:04:20
问题 I have an AWS API Gateway setup, served by a Python Lambda function. For successful responses the Lambda returns a response of the form: "200:{\"somekey\": \"somevalue\"}" By default, the Integration Response settings in the gateway console have just one rule configured with a Lambda Error Regex of .* mapping to a response status of 200. This works fine. The problem is when I try to change that to 200.* (with a view to enabling more specific codes going forward). Now I get a {"message":

Fail to enable CORS for API Gateway functions

折月煮酒 提交于 2019-12-21 03:26:12
问题 I get While attempting to enable CORS on API Gateway, why is that and how do I resolve this? These functions are deployed using AWS SAM. But I notice if I create my own APIs via AWS Console this happens too The errors looks like: invalid model name specified application/json=Empty invalid response status code specified I found I seem to need to add an "Empty" response model myself? Now, I get Add Access-Control-Allow-Origin Integration Response Header Mapping to POST method (invalid response

AWS API-Gateway communicating to SNS

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 10:32:44
问题 I am building an API which will be serviced by Lambda functions but I need these to be asynchronous so rather than connecting the API-Gateway directly to the Lambda function I'm using the "AWS Service Proxy" to publish SNS messages and then have the Lambda function subscribe to the relevant SNS topic so it receives delivery of the requests. Here's a picture which illustrates the flow: I have tested both the Lambda function in isolation as well pub/sub messaging between SNS and Lambda but I am