I am trying to orchestrate UI calls using step function with the minimal impact. Currently I have a lambda function that can be called using different URLs via API gateway, for instance, following URLs are used to call the same lambda:
http://base.url/orders/get/order/{userid}
http://base.url/orders/get/allorders/
I know that it isn't a best practice for lambdas, but we have what we have. Now I need to add a step function between API gateway and lambda to orchestrate calls. I need step function to be able to call step function using these urls, but I cannot understand how to do that.
Here are some links that I already checked:
https://docs.aws.amazon.com/step-functions/latest/dg/concepts-input-output-filtering.html
https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-paths.html
https://docs.aws.amazon.com/step-functions/latest/dg/connect-parameters.html
Is there a way to do what I need to do?
It sounds like you just need to format the message to the lambda in a way that looks like what would be coming from the API Gateway. If that's the case you can see what an API Gateway request would look like by selecting Amazon API Gateway AWS Proxy from the lambda test events in the console. From there you should be able to modify the payload to match your needs.
Related
I am using AWS API Gateway with HTTP API which invokes a lambda function. However HTTP API doesn't include USAGE feature. According to my requirement I need to create a usage for a client depending on the status code of the response sent back by the lambda. Since I cant access the response sent by lambda in API Gateway, I am looking for an custom solution. I am planing to use STEP function.
For example:
Instead of API Gateway directly invoking a lambda function it can call a STEP function where I can execute LambdaA. next it would trigger LambdaB with response from LambdaA as input to LambdaB in a sequential manner. I don't know If this is the right approach
I would like to know what is best way of solving this problem...thanks in advance
We have a requirement to write custom logs for the application to capture the things like who did what and when.
To do that we have created a Lambda to insert the logs in DynamoDb database. We need this Lambda to be called from a common place every time we call an API from frontend of the application instead of invoking it in each and every individual lambdas.
We tried invoking this in the API Gateway Authorizer but it doesn't work because our gateway authorizer is of type 'Token'. So, it does not accept any other parameters than access token. We cannot change the type of custom authorizer to type 'Request' because we need access token to be present for authorizing user in Cognito.
Question:
Is there any place where we can invoke this Logs Lambda so that it executes when each API is called?
Your last paragraph makes no sense but typically the best way to do this is streaming, as this minimises the amount of Lambda invocations you need to make.
You can stream API Access logs which contain things like the path, current time, principal to a cloudwatch log streams, or a lambda.
In this lambda you can do your custom logging logic there. If you have other sources which will have different types of events you may need to use Kinesis directly for streaming.
try using a different event trigger. If your lambda can get triggered by a queue or cloudfront you won't have authorization problems. however your application has to assume a suitable role to use some of these. If you're using Java, you can intercept your request in many ways and make the lambda call via SDK before processing the API. Need more details to provide a holistic solution.
I want to write a unit test for the availability of AWS lambda functions. Is there any way to GET AWS lambdas list. I know using CMD we can get the list of AWS function. But I want any other way to get the lambda functions list.
After research, I find out a rest API of all AWS services. But I didn't understand how to use them.
I found out AWS HTTP calls, links are attached https://docs.aws.amazon.com/general/latest/gr/rande.html.
Yes, you can do that using AWS Infrastructure REST API interface.
To do so,
You first need to create a signature 4 authentication key for every call you make.
Reference: Authenticating Requests (AWS Signature Version 4)
Then you need to pass it via Authorization header in any REST request.
Reference: Authenticating Requests: Using the Authorization Header (AWS Signature Version 4)
Finally, call using ListFunctions API.
Reference: ListFunctions
Call Example:
GET
/2015-03-31/functions/?FunctionVersion=FunctionVersion&Marker=Marker&MasterRegion=MasterRegion&MaxItems=MaxItems
HTTP/1.1
This gives you the list of Lambda functions deployed.
Hope it helps.
I want to publish my application and provide lambdas to other so that I want that on exporting the lambda package no one can get the lambda code.
You should create an API Gateway which will connect the application to your Lambda code. Give that API endpoint URL to the others and they will call your Lambda function through that. This way they cannot know what's going on in your Lambda code.
Ideal way is to use API gateway and use it as trigger for your Lambda and share that endpoint to the users.
However if you don't want that you should probably consider cross account access with cross account role (give permission to execute just the Lamnda you want to expose & setup trust relationship) . Let them assume this role and call this lambda.
I have a lambda function that I'd like to trigger via HTTP request.
When I click add trigger to a lambda function, I get an API Gateway API set up with:
method: ANY
Great. Now, when viewing this lambda function, I see a trigger has been configured.
However, I would like to restrict the trigger to only allow POST requests.
So I deleted the API Gateway method ANY, and created a new method POST, under the same resource, using an integration type of Lambda Function. I select my region, and sure enough, my existing lambda function is autocompleted.
However, when I view the triggers tab on the lambda function itself, it shows that there are no triggers.
What am I missing?
If you need flexible control of the API, I would suggest to use the API Gateway console to mange your API. Lambda triggers should only be used for simple use-cases - API methods configured through API Gateway will not show up in the Lambda triggers list.