aws-api-gateway

Kinesis Firehose putting JSON objects in S3 without seperator comma

安稳与你 提交于 2019-12-07 08:12:58
问题 Before sending the data I am using JSON.stringify to the data and it looks like this {"data": [{"key1": value1, "key2": value2}, {"key1": value1, "key2": value2}]} But once it passes through AWS API Gateway and Kinesis Firehose puts it to S3 it looks like this { "key1": value1, "key2": value2 }{ "key1": value1, "key2": value2 } The seperator comma between the JSON objects are gone but I need it to process data properly. Template in the API Gateway: #set($root = $input.path('$')) {

Request body serialization differences when lambda function invoked via API Gateway v Lambda Console

时光毁灭记忆、已成空白 提交于 2019-12-07 04:16:48
问题 I have a simple API set up in AWS API Gateway. It is set to invoke a Python 2.7 lambda function via API Gateway Proxy integration. I hit a strange error in that the lambda worked (processed the body correctly and updated a DB) when invoked locally and through the lambda test console, but not through curl or Postman. Turns out that, when invoked through the lambda test console, the event['body'] object is coming through as a dict . When called via an HTTP client, it's coming through as a

AWS API Gateway CORS pre-flight check fails

☆樱花仙子☆ 提交于 2019-12-07 03:27:23
问题 I'm using Zappa to deploy my application, cors is enabled and everything seems to work OK when pressing the "test" button on the options in API Gateway "OPTIONS" resource. However, when I try to do the CORS pre-flight check, I get a 500 error with body {"message": "Internal server error"} and CloudWatch logs Execution failed due to configuration error: Unable to transform request EDIT : This is what the configuration looks like: EDIT 2 I've tried enabling the CORS by both via zappa_settings

AWS Chalice Return an Image File from S3

别等时光非礼了梦想. 提交于 2019-12-06 22:26:37
I am using Chalice to build a simple severless application which returns an image file from S3. I am able to return file after it is 64 bit encoded. But I am wondering how I can return the binary file so that user can take it as a file download? My following code is not working. @app.route('/binary_object/{bucket}/{key}', methods=['GET', 'PUT']) def binary_object(bucket, key): request = app.current_request if request.method == 'GET': try: file_path = '/tmp/{}_{}'.format(uuid.uuid4(), key) s3_client.download_file(bucket, key, file_path) file_size = os.path.getsize(file_path) headers = {'Content

Export existing AWS Lambda and API Gateway to Cloudformation template

ⅰ亾dé卋堺 提交于 2019-12-06 21:30:06
问题 How to export existing configured and tested infrastructure (including AWS Lambda functions, API Gateways, ElastiCache clusters, Cloudwatch rules) to Cloudformation template? I know about Cloudformer tool, but it supports limited number of AWS services (Amazon VPC, DynamoDB, etc) and don't supports some of services which we use. Which tools and approaches can I use in my case for generating Cloudformation template? 回答1: Partial solution: there is ability to export Lambda function to AWS SAM

AWS Cloudformation Link API Key to API Gateway

喜夏-厌秋 提交于 2019-12-06 20:28:30
I have the following Cloudformation template I am trying to deploy via SAM. This template correctly creates the DynamoDB table, an API Key, a Lambda function and the API Gateway, but I cannot figure out what I need to specify in the template to associate the API KEY with the API Gateway. I have found plenty of snippets showing partial examples, but I am struggling to piece it all together. Thank you in advance, Denny AWSTemplateFormatVersion: 2010-09-09 Transform: AWS::Serverless-2016-10-31 Parameters: TableName: Type: String Default: 'influencetabletest' Description: (Required) The name of

Custom domain for API Gateway returning 403

时光毁灭记忆、已成空白 提交于 2019-12-06 16:51:07
问题 I am creating an api using API Gateway and Lambda. Using the url designated in the API Gateway Stage editor everything works fine; however, when I try and move to a custom domain I am running into some issues. The first thing I tried was using a CNAME record in Route 53 straight from my domain onto the domain that I got from the API Gateway. That was returning some errors and I think it is the incorrect solution is that correct? Next I tried the Custom Domain Names feature in API Gateway. My

Node Middleware Without Express

半城伤御伤魂 提交于 2019-12-06 16:01:58
I'm building an AWS Lambda Server to Integrate with API Gateway and I'm unable to expose the server so that I can hook it into Express. I'm wondering if anyone knows a best practice for using middleware without Express. Here is my code. var jobs = require('./jobs'); var http = require('http') const server = http.createServer() server.on('request', (req, res) => { //I want to be able to add a function here that executes all of the middleware that I specify. const { headers, method, url } = req; let body = []; if(url) enableCors(res); res.writeHead(200, {'Content-Type': 'application/json'})

Setting up proxy_pass on nginx to make API calls to API Gateway

岁酱吖の 提交于 2019-12-06 15:21:46
Problem: I've set up a Lambda function behind API gateway which works beautifully. I have a hosted site that I want only a certain location to hit the API. Example https://www.example.com/ (Serves up html from hosted server) https://www.example.com/foobar (Returns a JSON payload that is generated by Lambda and returned by AWS) Here is my server block: location = /foobar { proxy_pass https://someawsuri; proxy_redirect default; } location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } I've tried reviewing the

AWS API Gateway default response and Trigger AWS Lambda

℡╲_俬逩灬. 提交于 2019-12-06 14:04:28
I have been experimenting with AWS API Gateway and AWS Lambda to try out a serverless architecture. Have been going through blogs and AWS documentation. Have tried out sample GET/POST. But, I have the following requirement w.r.t tracking user events from my custom application Events are posted from my application to API end point I wanted the API to respond back with a custom response (Say {'fine'}) (acknowledging that the request has been received) After the response is sent, hand over the event payload to a AWS Lambda function As per the documentation, I understand, a) I can post events to