In this tutorial we will show you how to create a Workflow that controls tags applied when a new EC2 instance is created.
This enables a simple way to manage and use best practices, as the Automation checks the tags as soon as the instance is created on your account. The Workflow determines whether one or less tags are applied to the instance, and if so it will notify a predefined channel or user on Slack.
Before we begin:
Creating Workflow Steps:
if
Step to check if there is one or less tags assigned to the new EC2 instance.Testing the Workflow.
A Pack is a collection of Workflows. If you already have a Pack you can open it and skip ahead to creating a new Workflow . If you don’t have an existing pack, follow these steps:
Proceed to create the Steps of your Workflow as described in the following section.
if
Step to check if there is one or less tags assigned to the new EC2 instanceif
Step by clicking {{len(event_payload.tags)}} Less or equals to equals 1
If one tag or less is found, Step 2 occurs.
If more than one tag is found, Workflow stops.Click to open the Action panel. Alternatively, you can drag Actions to your flow, from the menu on the left side of your Edit screen.
Search and select the Slack > Send message to channel Action.
For the Step to work, a connection to Slack is required. On the right-hand corner of your Step, select Select Connection > slack_connection. If you do not have a Slack connection, click Create new connection.
Enter the following parameters in your Step.
Parameter | Description | Example |
---|---|---|
Channel | Receipts channel name. | Random |
Text | Descriptive text. | The following instance {{event_payload.instance}} in{{event_payload.placement}} violates tagging policy. Here are the attached tags. {{len(event_payload.tags)}} |
You can test your Workflow before you publish it. An event-based Workflow can be tested using a JSON sample of a potential incoming event. To run a test, use the following instructions: