aws-api-gateway

api gateway regional custom domain is not working

为君一笑 提交于 2019-12-05 23:31:09
问题 I'm testing to make mobile game server with AWS's Lambda and API gateway. At the API gateway, I try to make custom domain using 2 types endpoint, regional a.domain.com and edge optimized b.domain.com . The edge optimized endpoint is fine, it works. But the regional endpoint is not working. it returns ERR_CONNECTION_REFUSED. the regional endpoint url can't submit to record set using aws console. So I'm using aws-cli for editing record set in the route53. 回答1: I had the same issue. It appears

Parse AWS API Gateway header in Lambda

╄→尐↘猪︶ㄣ 提交于 2019-12-05 21:29:16
I've created a lambda function and API gateway endpoint so that it echoes the query and header parameters it receives, and I want to parse the whole payload to JSON for manageability. The received payloads is in this form: "{Accept=*/*, Accept-Encoding=gzip, deflate, Accept-Language=nb-NO,nb;q=0.8,no;q=0.6,nn;q=0.4,en-US;q=0.2,en;q=0.2,sv;q=0.2,da;q=0.2, Authorization=COzTjCKD6VHTC, Cache-Control=no-cache, User-Agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36, Via=1.1 7822a0bcea47c939c09def064206add3.cloudfront.net

How can I use AWS CloudFront and API Gateway side by side for the same domain?

本小妞迷上赌 提交于 2019-12-05 20:04:29
I'm putting that static assets of my website on S3, and setting up CloudFront to distribute them. These essentially holds the content users would need for any GET request on my site, to existing paths that is, with a catchall for errors. I also have some POST requests I need to handle. Form submissions, sending emails, notifications, interacting with the database. How can I set up Lambda (or API Gateway) side by side with CloudFront for the same domain so that CloudFront handles GET requests, and API Gateway handles requests with a body or POST requests. Or can I do it by individual URL

AWS GET request with body rejected by CloudFront

落花浮王杯 提交于 2019-12-05 17:57:04
I'm build an API using AWS SAM (Lambda & API Gateway) whose contract is defined by a 3rd party. The 3rd party calls my API with a GET request that contains JSON in the body. However, when a request is sent to the API with a body it gets rejected by CloudFront. This is the request: curl -X GET -H "Content-Type: application/json" --data '{"hello":"world"}' https://my-api.execute-api.us-east-2.amazonaws.com/Prod/my-api This is the response: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT=

AWS Lambda Go function not getting request body when called via API GW

血红的双手。 提交于 2019-12-05 17:45:52
First off, one might say this question is very similar to HTTP request body not getting to AWS lambda function via AWS API Gateway or Getting json body in aws Lambda via API gateway However, none of these questions address using Golang, and the problem I have been having is finding an equivalent of the event parameter used everywhere in the Node.js documentation. Here's my Lambda Function: package main import ( "context" "encoding/json" "github.com/aws/aws-lambda-go/lambda" "github.com/aws/aws-lambda-go/events" "log" ) type MyReturn struct { Response string `json:"response"` } type

Kinesis Firehose putting JSON objects in S3 without seperator comma

杀马特。学长 韩版系。学妹 提交于 2019-12-05 14:49:42
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('$')) { "DeliveryStreamName": "some-delivery-stream", "Records": [ #foreach($r in $root.data) #set($data = "{ ""key1"": ""

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

和自甴很熟 提交于 2019-12-05 11:18:17
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 string ( Unicode ). I can work around it of course, but I'd like to understand it, and I'd also prefer a

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

徘徊边缘 提交于 2019-12-05 09:06:45
问题 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

AWS API Gateway CORS pre-flight check fails

╄→гoц情女王★ 提交于 2019-12-05 07:50:34
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.json ( "cors": true ) and by manually clicking enable cors in the AWS console Does anyone have any

Parse multipart request string in Python

此生再无相见时 提交于 2019-12-05 06:45:14
问题 I have a string like this "--5b34210d81fb44c5a0fdc1a1e5ce42c3\r\nContent-Disposition: form-data; name=\"author\"\r\n\r\nJohn Smith\r\n--5b34210d81fb44c5a0fdc1a1e5ce42c3\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example2.txt\"\r\nContent-Type: text/plain\r\nExpires: 0\r\n\r\nHello World\r\n--5b34210d81fb44c5a0fdc1a1e5ce42c3--\r\n" I also have request headers available in other vairbles. How do I easily parse this with Python3? I am handling a file upload in AWS Lambda via