aws-api-gateway

Using an api key in amazon api gateway

我是研究僧i 提交于 2019-11-29 02:06:56
问题 I have created an api key and added it to my functions. I have then deployed the api and tested it but still get: "message": "Forbidden" How do I pass the api key with my JSON request as I have been using "x-api-key": "theKey"? 回答1: The x-api-key parameter is passed as a HTTP header parameter (i.e. it is not added to the JSON body). How you pass HTTP headers depend on the HTTP client you use. For example, if you use curl and assuming that you POST the JSON payload, a request would look

Api gateway get output results from step function?

ぃ、小莉子 提交于 2019-11-29 01:43:20
I followed tutorial on creating and invoking step functions I'm getting output in my GET request of api as { "executionArn": "arn:aws:states:ap-northeast-1:123456789012:execution:HelloWorld:MyExecution", "startDate": 1.486772644911E9 } But, instead of above response I want my step functions output, which is given by end state as below. { "name":"Hellow World" } How to achieve this? AWS Step Functions are asynchronous and do not immediately return their results. API Gateway methods are synchronous and have a maximum timeout of 29 seconds. To get the function output from a Step Function, you

In Terraform, how do you specify an API Gateway endpoint with a variable in the request path?

旧街凉风 提交于 2019-11-29 00:06:45
问题 In AWS API Gateway, I have a endpoint defined as /users/{userId}/someAction , and I'm trying to recreate this with terraform I would start having some sort of linked gateway_resource chain like so... resource "aws_api_gateway_resource" "Users" { rest_api_id = "${var.rest_api_id}" parent_id = "${var.parent_id}" path_part = "users" } //{userId} here? resource "aws_api_gateway_resource" "SomeAction" { rest_api_id = "${var.rest_api_id}" parent_id = "${aws_api_gateway_resource.UserIdReference.id}"

How to authenticate API Gateway calls with Facebook?

南笙酒味 提交于 2019-11-28 21:37:39
Problem: I want to authorize my Amazon API Gateway hosted REST API users using Facebook Authentication. My Understanding: I know Amazon Cognito can be used to authenticate users, calling as Federated Identities. Then, I saw Authenticate API Clients with Amazon Cognito Your User Pool , which authenticates for Cognito User Pool. I also found Use Amazon API Gateway Custom Authorizers , to use from custom authorization. But, I did not find to link API Gateway to authenticate using Cognito Federated Identities (i.e. Facebook here). Can we use same procedure as User Pool for Federated Identities as

Get detailed error messages from AWS API Gateway Request Validator

旧时模样 提交于 2019-11-28 21:19:02
Background I have an API Gateway created using Swagger 2.0 definitions with API Gateway extensions . I overrode the default API Gateway responses, for instance: x-amazon-apigateway-gateway-responses: BAD_REQUEST_BODY: statusCode: 400 responseTemplates: application/json: | { "error": { "code": 400, "stage": "$context.stage", "request": "$context.requestId", "message": "$context.error.message" } } The $context in the above payload comes from API Gateway variables . A sample resource/method in my API looks like this (always LAMBDA_PROXY integrations): paths: /test: post: parameters: - in: body

How can I retrieve a user's public IP address via Amazon API Gateway + Lambda (node)

拥有回忆 提交于 2019-11-28 20:08:26
I'm currently writing a Node.js lambda function, in which I want to log the incoming requester's public IP address. I've been looking through both the API Gateway and Lambda docs all day, but haven't found a solution. Does the lambda event object include request metadata I can use to extract the user's IP? Kenneth Rory Dunn Here is a simple demonstration of using API Gateway's $context.identity.sourceIp in a Lambda function. API Mapping template: { "sourceIP" : "$context.identity.sourceIp" } Lambda function: 'use strict'; console.log('Loading function'); exports.handler = (event, context,

API Gateway authentication with Cognito Federated Identities

半世苍凉 提交于 2019-11-28 19:52:44
I want to use Cognito Federated Entity (allowing signin through Google etc), to allow access to API Gateway for a web javascript application. I managed to get the Cognito's sessionToken through signing-in with Google but I'm stuck on the API Gateway configuration for enabling the session token. Is there a good tutorial for this entire Federated Entity authentication workflow? Thanks! Since you want to invoke APIs via authenticated Cognito identity, first Amend the auth role of the identitypool to have api execute policy, you could just attach the managed policy

Lambda Integration vs. Lambda Proxy: Pros and Cons

梦想的初衷 提交于 2019-11-28 18:39:52
What do you think are the Pros and Cons of using Lambda integration with and without the proxy feature in AWS API Gateway (and more specifically, when using the Serverless framework)? Here's what I think up to now: Lambda Integration with Proxy Pro : One can rapidly prototype and code without worrying about all the needed configuration details (and reinventing a few wheels like generic template mappings, etc). Pro : It's really easy to return any status code and custom headers, while at the same time there's a generic way to read the body, headers, parameters, of the request. Con : Everything

How to CNAME to Amazon API Gateway Endpoint

蓝咒 提交于 2019-11-28 18:34:43
问题 I'm trying to set a CNAME on Cloudflare to point to an Amazon API Gateway endpoint. The CNAME is for use when referring to one of my subdomains. The gateway in turn points to the IP of a server on DigitalOcean. I am very new to Amazon web services and would appreciate if someone could give me an overview of the correct configuration for the DNS, Amazon Gateway and Cloudfront (which I think is needed to expose the gateway to DNS servers external to Amazon). Any help would be much appreciated.

How to pass a params from POST to AWS Lambda from Amazon API Gateway

半世苍凉 提交于 2019-11-28 16:31:20
In this question How to pass a querystring or route parameter to AWS Lambda from Amazon API Gateway shows how to map query string params to AWS lambda using API gateway. I would like to do the same but mapping POST values instead of query-string. I tried: { "values": "$input.params()" } but did not work, I don't see the actual form data. BTW I am posting using: application/x-www-form-urlencoded I get my response from my lambda function, so I know it is invoking lambda fine, but my problem is that I don't see the POST params anywhere. I can;t figure out how to map them. I dump all I get on