aws-api-gateway

CloudFormation API Gateway CORS issue access to XMLHttpRequest blocked

狂风中的少年 提交于 2019-12-06 13:51:54
问题 I'm trying to use CloudFormation to create an API Gateway but I have CORS issue with it. Error on the front-end: POST https://<>.execute-api.us-east-1.amazonaws.com/prod/<> 500 new:1 Access to XMLHttpRequest at '<>' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. The API is created without any issue and I even double check every single page on the console against the working API and find no

Get CloudFront custom domain in the headers of a request

大城市里の小女人 提交于 2019-12-06 12:44:01
I have a CloudFront distribution abcd1234.cloudfront.net and I've added a custom domain of mysite.com to the distribution. The CloudFront distribution's origin: aaabbbccc.execute-api.us-east-1.amazonaws.com When I load the page mysite.com/hello/world , CloudFront is then consuming API Gateway aaabbbccc.execute-api.us-east-1.amazonaws.com/prod/{proxy+} the API Gateway path endpoint is invoking a Lambda Function that calls a function like getPageContent(customDomainName, pagePath) which should be mysite.com and /hello/world respectively. However, inside that function, the Host header that

AWS Lambda - Unable to connect to SQL Server RDS

前提是你 提交于 2019-12-06 12:29:39
问题 Hi I was having the same problem as this post but the posted answer (no sample code) wasn't provided so I will start a new thread and ask you guys. I have created a AWS Serverless Application (.Net Core) project for our lambda function and below code is what I used to connect in AWS RDS. string ConnectionString = "Data Source=rds4abc1190.asdfqwerqb9l.us-east-1.rds.amazonaws.com,2855;Initial Catalog=MyDatabase;Persist Security Info=True;User ID=myID;Password=mypassword;Encrypt=False"; using

AWS API gateway body mapping template for dynamodb map

删除回忆录丶 提交于 2019-12-06 11:31:22
I am trying to figure out how to insert dynamic data into a dynamodb table via an API Gateway in AWS. Currently I have a dynamodb table and an API endpoint setup that accepts a POST like so. POST https://{unique-id}.execute-api.us.east-1.amazonaws.com/notification/events { "reference_number": 99, "purchase_date": "1/1/2017" } I've setup a body mapping template in the API gateway to massage the data into the dynamodb. { "TableName": "Events", "Item": { "reference_number": { "N": "$input.path('$.reference_number')" }, "purchase_date": { "S": "$input.path('$.purchase_date')" } } } The above works

How to - AWS Rest API Authentication

℡╲_俬逩灬. 提交于 2019-12-06 10:49:45
I'm trying to make a Rest API using AWS API Gateway, Lambda, and DynamoDB. I'm using java-script as my lambda language, and I have successfully created some resources already. However, i don't understand how to make authenticated requests to my IP. I want simple HTTP Authentication. Can someone explain how to make authenticated requests to the API Gateway and Lambda? Here is very Good GitHub Lambda Http Authentication Example Repository . You can walk through this example. A sample authentication service implemented with a server-less architecture, using AWS Lambda to host and execute the code

AWS API Gateway: Is it possible to add source IP address in each API method?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 10:32:03
I have created an API using AWS API Gateway. Now I want to log each of the request on each method of each resource. Also, I need the source IP address of the client accessing the route. How can I accomplish this without writing custom code in the API functions ? The default CloudWatch logs for your API should include all headers, including the X-Forwarded-For header which will contain the source IP address. (See http://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-stage-settings.html ) If you need custom logging you will need to implement this in your Lambda functions. You could

AWS API Gateway accept Content-type: application/xml

自古美人都是妖i 提交于 2019-12-06 10:29:31
问题 I've got a question about AWS API Gateway.. I want to process an other companies API into my own dynamoDB in AWS. They can only POST an XML formatted to my API. My setup is API Gateway -> Lambda -> DynamoDB. But how can do set up a API Gateway POST in such a way that i accepts the XML posted by them? Link to their XML Post setup (it's just the uplink data): http://zakelijke-community.kpn.com/t5/Data/Application-data-API/ta-p/4768 回答1: You can define a request mapping template for "application

Accessing AWS API Gateway from an EC2 using IAM authorization (NodeJS)

痞子三分冷 提交于 2019-12-06 09:23:38
Perhaps I'm going a bridge to far here but heres what I got: An AWS API Gateway Method that has AWS_IAM set for Authorization. A Policy that allows access to that Method. An EC2 Role that has that policy attached to it. An EC2 Launched with that Role. I would like to have my NodeJS program (or any language for that matter) on that EC2 to be able to call that API without hardcoding an AccessKey and SecretKey in the code. I have used this approach to use the aws-sdk to put/get records on S3, and do other AWS functionality (like all the steps I mentioned above), However, invoking an API Gateway

AWS API Gateway with custom authorizer returns AuthorizerConfigurationException

我怕爱的太早我们不能终老 提交于 2019-12-06 09:06:19
I have an AWS API Gateway that uses a custom authorizer, and if the request is authorized, it triggers another lambda function. Since yesterday, whenever I call the API, I get an error saying { "message": null } and a 500 Internal Server Error. In the response headers it says x-amzn-ErrorType →AuthorizerConfigurationException . I can see in the logs that the authorizer is called and returns a valid policy, and that the other lambda function is not triggered. I have not (knowingly) changed the authorizer. Can anyone give me a hint what might be wrong here? I have read this question but there

How can I make an IP/VPC whitelist for an API in API Gateway?

青春壹個敷衍的年華 提交于 2019-12-06 08:13:04
We have an API in API Gateway connected to a lambda function. The API has three stages (Dev/Stage/Prod), an API key (required) and a usage plan (connected to all three stages). We're trying to restrict traffic to this API so that Stage/Prod is only accessible from our servers from within our VPC, and Dev is only accessible from our office IP. We have tried using the Resource Policy below, but it doesn't work. Stage/Prod is still accessible from our office IP. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": "*", "Action": "execute-api:Invoke", "Resource": "arn:aws