aws-api-gateway

Inbuilt authentication mechanism - API gateway

跟風遠走 提交于 2019-12-02 18:28:12
问题 API gateway has in-built functionality to perform authorization. But the examples provided by awslabs have lambda hooked to API gateway, where lambda is authorizing as per this code for a below API gateway: MyApi: Type: AWS::Serverless::Api Properties: StageName: Prod Auth: DefaultAuthorizer: MyLambdaRequestAuthorizer Authorizers: MyLambdaRequestAuthorizer: FunctionPayloadType: REQUEST FunctionArn: !GetAtt MyAuthFunction.Arn So, auth token provided by client is received by lambda and then

How to point ApiGateway to a specific Lambda alias

喜你入骨 提交于 2019-12-02 18:08:12
I created a resource in Amazon's ApiGateway. It is pointing to a Lambda function. This is being hit by a native mobile application (android and ios) which is already in the wild. I now want to modify the Lambda function, but I see no way to change my ApiGateway resource to point to an alias of the lambda. This is my first time playing with any of these technologies and I see no easy mechanism to manage this in the aws console. How can I modify my ApiGateway resource to point to my lambda alias so I can edit trunk without affecting existing clients? Under Integration Type -> Lambda Function you

How to add a custom domain for a serverless-1.0.0 framework defined/deployed API?

最后都变了- 提交于 2019-12-02 16:21:31
Serverless-1.0.0-rc.1 enables to deploy an API to be accessible via a AWS API Gateway. The question: I need the deployed API exposed via a custom domain with SSL certificate instead of the randomly assigned one (URL https://qwertylgbtqert.execute-api.... )? Can that be done from within serverless.yml or serverless framework? Here is my simple service serverless.yml definition: service: my-service provider: name: aws runtime: nodejs4.3 functions: generate: handler: handler.generate events: - http: method: get path: url cors: true There is an question which relates to this: the answer here , but

Aws Api Gateway Integration Request How to append a property to request body?

柔情痞子 提交于 2019-12-02 14:03:24
问题 I want to combine request body and querystring parameters before sending it to lambda. Let's say I have an entity in Lambda as below : Class Person { private String firstName; private String lastName; private String language; } And the json which sent to api gateway is {"firstName":"Foo","lastName":"Bar"} As you see "language" field is missing in request body. I want to get this language field from querystring and add to json. How can I achieve tihs ? Is there a way to do in integration

AWS: Restrict Cognito Authorized User to specific Lambda Functions

纵然是瞬间 提交于 2019-12-02 13:40:18
问题 I'm working with AWS and I've the following setup: UserPool; API Gateway, Lambda Functions The api gateway is using a UserPool authorizer to protect the lambda functions. This is working so far. Now I want to restrict every lambda function to a specific group of users. Therefore I've created two user groups in the CognitoPool ( user and admin ) and I've assigned a specific role to each group with a policy. Afterwards I've created a user in the UserPool and added him to the user group. That

Amazon API security with API Keys?

假如想象 提交于 2019-12-02 11:00:59
I have deployed my rest API on amazon API gateway and I have a scenario in front of me with security concern. I am using an api key for all the api requests, I wanna know if the that api key is exposed somehow and as we know the same api key is being used by already published apps...Then what are my options? Also as mentioned here I can have only 10000 API keys per AWS account if I want the api keys to be unique per user for it to be more secure but what if the number of user shoots out to be more than 10000. Please suggest on the same as it is very important. API keys are not recommended for

Reading Event Parameters AWS lambda

。_饼干妹妹 提交于 2019-12-02 10:33:04
问题 I have a lambda function (Node.js 4.3) as below: exports.handler = function(event, context, callback) { console.log('Received event:', JSON.stringify(event, null, 2)); var greeter = 'World'; if (event.greeter && event.greeter!=="" && event.greeter1 && event.greeter1!=="") { console.log('Received 1'); greeter = event.greeter + event.greeter1 ; } else if (event.body && event.body !== "") { console.log('Received Body'); var body = JSON.parse(event.body); if (body.greeter && body.greeter !== "")

Monitor API Gateway APIs based on API key

99封情书 提交于 2019-12-02 10:31:32
问题 How can I monitor my Amazon API Gateway APIs API key wise? Currently it is showing data for all API keys, but I want to display API calls, 5xx errors, 4xx errors etc for particular API key. 回答1: If you're looking at monitoring the API on X-Api-Key header level, it looks like this is currently not possible. I'm guessing you'd have to do it yourself on the application layer, which should be relatively easy if you're using Lambda . Your question brings up another question: Does it really make

Can't enable CORS on Lambda + API Gateway + Cloudfront on the Cloudfront layer

百般思念 提交于 2019-12-02 10:16:38
I have deployed a lambda, which in itself returns an 'Access-Control-Allow-Origin': '*' header in it's response. I call it from an API Gateway. When calling the API gateway URL, the CORS configuration is fine. I placed CloudFront in front of the API, however now I am unable to access the API as the CORS configuration seems to be overridden by CloudFront, and I am not sure where to add custom headers in CloudFront. How do you enable CORS inside CloudFront? Go into your CloudFront distribution, click behaviours, select each behaviour and click edit, you'll see the section titled whitelist

Lambda function -> Api Gateway stage variable permission manually

☆樱花仙子☆ 提交于 2019-12-02 09:08:08
You defined your Lambda function as a stage variable; you must manually give permissions to all the functions you will use. You can do this by running the below AWS CLI command for each function, replacing the stage variable in the function-name parameter with the necessary function name. aws lambda add-permission --function-name arn:aws:lambda:eu-west-1:12345:function:test${stageVariables.functionAlias} --source-arn arn:aws:execute-api:eu-west-1:12345:dsad667asd/*/GET/test/test --principal apigateway.amazonaws.com --statement-id d5a14508-22bb-4413-87c9-d9715e36435d --action lambda