The AWS Lambda action connector lets you configure and execute a Lambda function that is invoked in response to an event generated in the Contentstack.
Note: You need to define the Lambda function in your AWS Services console before configuring it to the Automations AWS Lambda action connector.
For instance, consider a scenario where you want to be notified whenever someone creates or updates an entry in Contentstack. In this case, you can set up a system that includes a webhook that triggers when a user creates or updates an entry. This webhook in turn must invoke a lambda function that notify a messaging service such as AWS SNS.
Set Up AWS Lambda action Connector
Perform the following steps to set up the AWS Lambda action connector:
- In the Configure Action window, select the AWS Lambda action connector.
- Select the Execute Lambda Function action.
- Click on + Add New Account to add your AWS account.
- In the Authorize pop-up window, provide details such as Title, Access Key, Secret Access Key, and Region.
You can generate the Access and Secret Access Key by navigating through Security credentials > Access Keys > Create New Access Key in your AWS console.
Additional Resource: For more information, refer to the Managing access keys for IAM users document.
- Once done, click on Authorize.
- Click on the Function Name textbox and select the required lambda function from the LOOKUP drop-down.
Note: You need to have your Lambda function defined in your AWS Services console before configuring your AWS Lambda action connector in Automations.
- Click on the Invocation Type textbox and select an option from the given drop-down. Here, you can choose from three options: Event, RequestResponse, and DryRun.
- Event: This returns a request ID and status code after successful execution of the function.
- RequestResponse: This returns a status code and a response message as body for the selected lambda function.
- DryRun: This allows you to test the function, and it returns a request ID and status code.
Let’s select Event as the invocation type for our first example, then we will cover other invocation types proceeding further.
- [Optional] You can choose to add optional fields by clicking on the Show optional fields toggle. You will find two additional fields have appeared: Parameters and Specific Version or Tag.
- Click on the Parameters textbox to add dynamic parameters to your Lambda function. Make sure to enter the parameter in JSON format only.
You can also specify a Specific Version or Tag for your Lambda function.
- Once done, click on Proceed.
- Click on Test Action to test the configured action connector.
- After successful execution, you will get a Request ID and status code for your Lambda function. Click on Save and Exit to finish the process.
Now, in continuation to step 7 above, let’s check out the output for the Invocation types RequestResponse and DryRun.
Invocation Type: RequestResponse
After performing steps 1-6 from above, perform the following steps:
- Select RequestResponse as the Invocation type.
- [Optional] Click on the Show optional fields toggle.
Add dynamic parameters (in JSON format) to your Lambda function under the Parameters textbox. And, specify a Specific Version or Tag for your Lambda function if need be.
- Once done, click on Proceed.
- Click on Test Action to test the configured action connector.
- After successful execution, you will get a status code and a response message (body) for your Lambda function. Click on Save and Exit to finish setting up your connector.
Invocation Type: DryRun
After performing steps 1-6 that we covered under setting up the Event invocation type, perform the following steps:
- Select DryRun as the Invocation type.
- [Optional] Click on the Show optional fields toggle.
Add dynamic parameters (in JSON format) to your Lambda function under the Parameters textbox. And, specify a Specific Version or Tag for your Lambda function if need be.
- Once done, click on Proceed.
- Click on Test Action to test the configured action connector.
- After successful execution, you will get a Request ID and status code for your Lambda function. Click on Save and Exit to finish the process.
This sets the AWS Lambda action connector.