I'm trying to configure data mappings from method request data from an API.
VTL as used in AWS API Gateway. Can I use Generic Tools like JsonTool or MathTool in the Mapping Template section?
Related
Is there any way I can rename request parameters at API gateway itself instead of changing cloud function code, like appVersion to app_version
In AWS api gateway I had used requestTemplates of x-amazon-apigateway-integration
Use Case: I need to perform an API request mapping that requires data from DynamoDB.
Desired Solution: I'd like to do this using API Gateway features if possible, which would look something like this:
An external REST API request is received by API Gateway
A Proxy Resource extracts a parameter, say accountId, from the HTTP path
A Service Integration (GetItem) reads a set of values from DynamoDB using the accountId key
The values read from the DB are input to a Request Mapper VTL template
The transformed API request is then sent to an HTTP Integration endpoint
Questions:
Is that possible to do using API Gateway out-of-the-box or is that sequence too advanced?
If it's not possible, then is a lambda the best option to do most of this work (read DB, transform request, route HTTP)?
Thanks for your help!
API Gateway will not make DB queries for you. Routing this through a Lambda function is the best option here.
I am trying to create a service root endpoint which will respond with a list of all existing path templates. I can create the response manually. Is there any way to get the list other than this manual approach?
If you are using serverless with aws + API Gateway you probably can use get resources method from the API Gatway methods from the aws sdk
example in JS sdk:
https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/APIGateway.html#getResources-property
I am new to AWS and I am setting up a API Gateway which will call a Lambda function that will post that data to a Kinesis Stream. The API Gateway Post request will contain several request parameters.
I am reading through the AWS docs and I see 2 options for accessing the request parameters.
1) Via the $input Variable doc
2) via Proxy Integration doc
Can you please explain the use case for proxy integration vs using the input variable?
Basically, if you control the backend integration interface (as you would with a Lambda function) you should use the 'proxy' integration because it's much easier to manipulate the data in your Lambda function code than in the API Gateway transformation.
If you don't control the backend integration interface (like Kinesis directly, or a legacy HTTP endpoint for example) then you can use the mapping template to transform the data between the client and the backend integration.
Does that make sense? For your use case using Lambda, you should use the proxy. If you wanted to try to use Kinesis directly as the backend, you would have to use a mapping template to construct the correct request to Kinesis.
Is there a way to configure the HTTP Proxy for all methods of resource at once so
FIRST:
GET,POST,PUT,DELETE of /v1/resource should all be forwarded to http://api.com/resource/{id}
If that is possible can I still map:
GET /v1/resource/schema to an S3 ?
or do i have to define them one by one.
The emergency way to save some time is probably to generate a swagger API documentation and create the API Gateway setup of it.
API Gateway doesn't support to set up multiple methods for one resource at once. As you already mentioned, you could create a Swagger template and use the API Gateway Importer tool (https://github.com/awslabs/aws-apigateway-importer).
Best,
Jurgen