Jinja 2 is "a template engine built with Python that can be used to create HTML, XML or other markup formats that are returned to the user via an HTTP response." To learn more, you can read about it here.
Within InsightCloudSec, certain actions in BotFactory, have the ability to leverage Jinja2 templating in the message body. This capability enables Bot authors to insert a variety of useful data about resources into the message.
On this page we will walk you through some examples of configuring Jinja2 and the steps required to use these templates within your Bot. We also have a full page of Jinja2 - References that include details on syntax, sample custom messages, and some examples of more advanced policy.
Before getting started with Jinja2 you will need to have the following:
- The appropriate permissions to create a Bot
- Completed integrations for any external tools you may want to use to send messages (e.g. SMTP for email, Slack, or MS Teams)
Other Important Information
- For information on our supported integrations check out the Integrations Overview page.
- For information on configuring email notifications check out the SMTP (Email Notifications) page.
If you have additional questions reach out to our team through the Customer Support Portal.
The following Bot actions support the Jinja2 capabilities outlined here:
- Send Delayed Email (see example messages below)
- Post Request To URL
- Send Slack Message
- Set Container Policy (see custom policies examples below)
- Assign Tag to Resource
- Send MS Teams Message
- Enable Storage Container Logging
- ServiceNow Incident
- Splunk Event
- Create Individual Jira Issue
- Publish to AWS CloudWatch Logs
- Publish to Notification Topic With Target Selection
Using Jinja2 in a Slack Message
In this example we will walk through the steps required to set up a Slack notification with a customized message when new volumes are provisioned. The Slack message will use Jinja2 templating and contain the account name and availability zone where the volume resides.
Before you get started, make sure your Slack Integration is already configured.
- From your InsightCloudSec platform, navigate to the Automation > BotFactory section.
- Select Create Bot to launch the bot creation process. Complete your Bot details (About Bot, Resource Types & Groups, Filters)
- Under Actions select Send Slack Message and specify the following:
- Slack Channel - where you want the message to be delivered within Slack
- Username - this is who the message will be originating from
- Tags (optional) - to assign recipients via tags
- Badges (optional) - to assign recipients via badges
- Under Actions include the contents of your Jinja2 template/message.
- Note: Slack also includes the capability to preview this message before finalizing the creation of the Bot.
- Check out example messages on the Jinja2 - References page.
- Complete your message details, click Next to add any additional Run Options and when you're satisfied that your Bot is complete click Save.
Using Jinja2 in a Delayed Email
In this example we will walk through the steps required to use Jinja2 to configure a 'Send Delayed Email' notification. This action will send an email to the admin team when a new instance is provisioned, allowing the admin team to see any new resource that can impact the monthly bill.
Before you get started, make sure your SMTP (Email Notifications) is already configured.
From your InsightCloudSec platform, navigate to the Automation > BotFactory section.
Select Create Bot to launch the bot creation process. Complete your Bot details (About Bot, Resource Types & Groups, Filters)
Under Actions select Send Delayed Email and specify the following:
- Subject Line - the subject of the email
- Contents of the message - the contents of the email (including Jijna2 template details)
- Email address for "from" - the email address that the message is being sent "from"
- Recipients - the email address(es) for the contacts that will receive the message
Complete your message details, click Next to add any additional Run Options and when your satisfied that your Bot is complete click Save.
Check out example messages on the Jinja2 - References page.
Explore the Resource attributes and functions to understand the requirements for configuring your desired template attributes.
In addition, you can take advantage of existing custom messages and read through details around resource functions. Head over to the Jinja2 - References page to see those details.