aws-api-gateway

API Gateway HTTP Proxy integration with serverless-offline (NOT Lambda Proxy)

瘦欲@ 提交于 2019-12-31 02:24:07
问题 I am trying to use serverless-offline to develop / simulate my API Gateway locally. My API gateway makes liberal use of the HTTP proxy integrations. The production Resource looks like this: I have created a serverless-offline configuration based on a few documents and discussion which say that it is possible to define an HTTP Proxy integration using Cloud Formation configuration: httpProxyWithApiGateway.md - Setting an HTTP Proxy on API Gateway by using Serverless framework. Setting an HTTP

Integrating AWS API Gateway with Cloud Front without exposing origin

╄→гoц情女王★ 提交于 2019-12-30 12:50:08
问题 I'm working on a project with serverless architecture. I've found that though AWS said API Gateway can protect your resources from DDoS attack. But if there is a bad user which keep sending spam to your service, API gateway can't provide an appropriate way to handle this kind of issues. So I start to figure out what I can do: AWS WAF is an obviously solution. I've found this post on stackoverflow: API gateway with aws waf Then in order to setup WAF, I put a Cloud Front distribution in front

How to make different AWS API gateway environments point to different aliases of a lambda function?

僤鯓⒐⒋嵵緔 提交于 2019-12-30 11:21:22
问题 In my AWS API Gateway API, I've set up 2 environments, "dev" and "prod". I also have 2 aliases for an AWS lambda function named "dev" and "prod". Now, I'd like to point the "dev" environment of my API to the "dev" alias of my function, and the "prod" environment at the "prod" alias of my function. I read in a tutorial that I can't find anymore at the moment, that in the integration configuration, you can specify the function in the form <functionName>:<alias> , so I set up the integration to

custom authorizers in Amazon API Gateway 500 error

别等时光非礼了梦想. 提交于 2019-12-30 09:27:46
问题 I use Serverless-Authentication-boilerplate and want to map custom error response. But it always return 500 error. authorize.js // Authorize function authorize(event, callback) { let providerConfig = config(event); try { let data = utils.readToken(event.authorizationToken, providerConfig.token_secret); console.log("Decrypted data: " + JSON.stringify(data)); let methodArn = event.methodArn.replace(/(GET|POST|PUT|DELETE)/g, '*').replace(/mgnt.+/g, 'mgnt/*'); console.log(`Change methodArn to: $

Request validation using serverless framework

巧了我就是萌 提交于 2019-12-30 04:29:08
问题 I am using serverless framework for the backend. How can I implement request validation? (do not want to write validation inside lambda functions). 回答1: To implement request validation using serverless you need to do a couple of things: Include your model/header definitions in your stack, and then tell API gateway to use them for request validation. You'll need to install the following packages: serverless-aws-documentation serverless-reqvalidator-plugin And then you'll need to include them

AWS Api Gateway Authorizer + Cognito User Pool Not Working {“message”: “Unauthorized”}

て烟熏妆下的殇ゞ 提交于 2019-12-30 01:03:43
问题 I am trying to use aws api gateway authorizer with cognito user pool. It is working fine when i test using aws api gateway console. But when i try enabling the authorization in the api it says "message": "Unauthorized". Please check below screenshot API Gateway Console Screenshot - This works fine Postman Screen shot - Not working Can someone help please. FYI I have followed the instructions as mentioned here http://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate

Configure CORS response headers on AWS Lambda?

蓝咒 提交于 2019-12-29 01:32:43
问题 I'm trying to create a new service using AWS API Gateway, but I found out the browser automatically calls OPTIONS method in order to obtain CORS information. The problem is that AWS API Gateway does not offer a native way to configure CORS headers. Is it possible to create a Lambda Script in order to respond to OPTIONS method? 回答1: If you're using {proxy+} endpoint, you must handle CORS HTTP requests in the Lambda function. The implementation depends on the framework you're using. For Express

Return HTML from AWS API Gateway

社会主义新天地 提交于 2019-12-28 09:18:22
问题 I am trying to achieve the same thing as this post, but I do not understand the reply there and don't have permission to ask for clarification in the comments. I have an API Gateway endpoint that accepts a GET request, passes through some request variables to the Lambda function (implemented in Python), and returns text/html via an Empty Response Model (as described here As described in the earlier SO question, if the Lambda function returns an HTML string and the API endpoint uses the

How do I get a pre-signed url for an API Gateway in Cloudformation using Boto3?

寵の児 提交于 2019-12-25 12:56:30
问题 I want to make a call to an API Gateway maintained in Cloudformation. I have the Cloudformation stack name ( CF_STACK_NAME ), the API Gateway resource name ( API_GATEWAY_NAME ), and Cloudformation name of the IAM Role I need to assume ( API_ROLE_NAME ). I can get to my Cloudformation stack via, cf_client = boto3.client('cloudformation') api_role_resource = cf_client.describe_stack_resource( StackName=CF_STACK_NAME, LogicalResourceId=API_ROLE_NAME ) api_resource = cf_client.describe_stack

how to pass the variable from api gateway to the url of another service running on EC2

夙愿已清 提交于 2019-12-25 09:45:15
问题 I am new to AWS. I am asked to use the services that is written in java and already exist in java EC2 to serve the UI. I need to use API gateway to call the services so the UI will first call the API gate way and then API gate way will call my service. Also I know that in Select Integration Request if I choose http proxy and add the url of my services on Ec2 I can achieve this. However the problem is that I have a service like this: http://domainname/article/{id} As you can see the id is a