AWS API Gateway: How to insert logs of each API call with output? - aws-api-gateway

I have a REST API created in AWS API Gateway with backend implemented using AWS Lambda functions. There are nearly 50 API calls and underlying lambda functions. Now I want to store each of the API call url, params and request body along with error/response to some log table in our database. Is there any way I can accomplish this without modifying the code of each and every lambda function for the same. I have a custom authorizer lambda function on most of the API calls. So, I thought about writing the logic to insert to DB in that function. But the problem is that I cannot get access to the output in the authorizer function. Is there any other way where I can access the input and output both ?

The custom authorizer function is intended to make authorization decisions only and is not supported for this use-case.
Please see response in AWS API Gateway: Is it possible to add source IP address in each API method?
Thanks,
Ryan

Related

Synchronous RestAPI with AWS API gateway and express stepfunctions

i am not able to invoke express stepfunction using restapi apigateway action type with StartSyncExecution
thanks in advance
Only HTTP API is currently supported, in order to invoke a step function using StartSyncExecution, you need to use the HTTP API.
Edit: It is now supported per the document in the comment below.

REST API calls for setting namespace preferences and Program preferences

Can the namespace preferences and program preferences be set via REST API calls? If yes, what is the syntax for it?
Generally in Cloud Data Fusion, when we intend to perform the action on GCP side, like create/delete/restart etc. instance, it's feasible to use domestic Google Cloud API, giving the opportunity to interact with a service endpoint via JSON/HTTP calls interface as described in Google Cloud API design document.
Dedicated to Data Fusion you can follow the Cloud Data Fusion REST API reference document, nicely explaining the methods for composing REST API HTTP calls to manage Data Fusion instances, moreover every method description from the documentation contains Google API Explorer sub-panel, to get handy experience building JSON request on a live data.
Said above, I assume your initial question is related more to CDAP REST API, as it includes the methods for pure CDAP instance metadata/namespaces/application configuration.
From the user perspective your workflow might be the following:
Identify the CDAP API endpoint as explained in this guideline;
Compose an HTTP PUT/GET request relevant to Data Fusion
Namespace/Metadata/Preferences/Configuration
object via CDAP RESTful API.
Yes of course! You have two methods.
The first method is creating it from the platform. Follow the steps below:
Open your data fusion instance
Go to System Admin => Configuration => Make HTTP calls
To create a namespace, submit an HTTP PUT request:
PUT /v3/namespaces/<namespace-id>
Link of CDAP: CDAP
The second method is using terraform.

Connecting to external database from Backand

I am currently working with a feature in our Ionic/Backand app that needs to access data from an external database (RedShift Cluster). I am thinking of the best way possible to accomplish this, and since we are using Backand as our backend, I thought if it was possible to make an action that could access RedShift Cluster and make SQL queries to it. Any help would be appreciated. Thanks!
Here is one option is
adding a generic lambda function to access AWS redshift,
Use AWS API Gateway to expose this lambda to Back &, (it is as secure as you want it to be, utilizing API key and AWS secret and access tokens of the IAM user)
Then calling this API in Back& server-side JS action by using $http object is a breeze

How to trigger a ngrok get request in AWS API gateway and Lambda function?

I'm trying to access some GET requests data from a personal ngrok webpage (that i created for testing purposes) by using the aws api gateway.
When i'm using the integration request i just can't get the data from the ngrok web page.
What i am trying to do is to catch some data from my ngrok page (by using the Api gateway) and then save them in dynamodb via a lambda function. I read the aws docs but i can find something that explains this process.
Thanks for helping.
One way is, you can have one API GW method that uses a Lambda function as integration endpoint. The Lambda function could get the data from ngrok page and save it to Dynamo.
The other way is, you can have one API GW method with http integration pointing to your ngrok endpoint, and another API GW method with Lambda integration pointing to your Lambda function that puts the data into Dynamo. The caller should call the first method, and then call the second method with the output of the first method. So, the first option is a better one.

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

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 take advantage of something like Apex or Serverless and write some automation to manage your Lambda functions and share duplicate code.