Tutorial for creating an Self-Service Workflow
In this tutorial we will show you how to create a Workflow that consumes a Terraform project. Based on calculated changes (Terraform plan) and escalation rules, it asks for approval and deploys the changes.
Once created, the Automated Workflow will be exposed in the Self-service portal of selected users and groups. Selected users are able to create a new environment on demand with an approval step, conditioned by your escalation rule.
In our example the project deploys a load-balanced web server. Approval will be required if the instance type selected by the user is not the default one or if deletion of resources is detected in calculated changes.
This is an overview of the procedure of creating the On-Demand Workflow.
Before we begin.
Creating Workflow Steps:
if
Step to control the workflow.if
Step to check answer.if
Step to control the workflow.if
Step to check answer.Defining output parameters. Testing the Automation. Exposing the Automation as a request in the Self-service portal.
A Pack is a collection of Workflows. If you already have a Pack you can open it and skip ahead to creating a new Automation. If you don’t have an existing pack, follow these steps:
Parameter Name | Description | Selection type | Options |
---|---|---|---|
instance_type | The size of the instance. | Single-select | t2.micro (default), t2.medium, t2.large |
reason | Reason for request. Will be sent with the approval request if the user selects a non default instance size. | String |
You have created an Automation with Input Parameters. Proceed to create the Steps of your Automation as described in the following section.
if
Step to control the workflowSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{inputs.instance_type}} | Not equals | t2.micro |
If the instance type is not t2.mirco. If the condition is met (need escalation), go to Step 2. If the condition is not met (instance type is t2.micro, thus no need for escalation), go to Step 5.
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 Asks questions via Slack 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.
Click on Action #2 to change the name of the action to Asking a question via Slack.
Enter the condition using the variable picker.
Parameter | Description | Example |
---|---|---|
Approver | Receipts emails address or channel name. | Random |
Question | Question to be answered. | *{{metadata.user_email}} is trying to use {{inputs.instance_type}}. Reason: {{inputs.reason}} |
Answers | Commas separating possible answers | Yes, No |
if
Step to check answerSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{steps.S2.output}} | Equals | No |
If the condition is met (answer is no), go to Step 4. If the condition is not met (answer is yes), go to Step 5.
Click and type Abort Step. No input parameters are required.
The commands calculates terraform plan and stores it in out.txt file, then it shows this plan in a json format.
if
Step to control the workflowSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{any(steps.S7.output.resource_changes, {'delete' in #.change.actions})}} | equals | true |
If the condition is met (need escalation), go to Step 10. If the condition is not met (no deleted resources, thus no need for escalation), go to Step 13.
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 Asks questions via Slack 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.
Click on Action #10 to change the name of the action to Asking a question via Slack.
Enter the condition using the variable picker.
Parameter | Description | Example |
---|---|---|
To | Receipts emails address or channel name. | Random |
Question | Question to be answered. | Apply the following changes: {{steps.S7.output}} For more details, refer to expression language. |
Answers | Commas separating possible answers | Yes, No |
if
Step to check answerSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{steps.S2.output}} | Equals | No |
If the condition is met (answer is no), go to Step 12. If the condition is not met (answer is yes), go to Step 13.
Click and type Abort Step. No input parameters are required.
You can test your Automation before you publish it.
Expose the Automation as a Request to make it available in the Self-service portal of other members.
The Self-service portal is found on the top left of your screen, click > Portal. All Workflows exposed to you are presented. Users with access to this request can use the Automation by filling in the input parameters and running the Request. The creator will get notified every new run of the Automation for auditing purposes.
Tutorial for creating an Self-Service Workflow
In this tutorial we will show you how to create a Workflow that consumes a Terraform project. Based on calculated changes (Terraform plan) and escalation rules, it asks for approval and deploys the changes.
Once created, the Automated Workflow will be exposed in the Self-service portal of selected users and groups. Selected users are able to create a new environment on demand with an approval step, conditioned by your escalation rule.
In our example the project deploys a load-balanced web server. Approval will be required if the instance type selected by the user is not the default one or if deletion of resources is detected in calculated changes.
This is an overview of the procedure of creating the On-Demand Workflow.
Before we begin.
Creating Workflow Steps:
if
Step to control the workflow.if
Step to check answer.if
Step to control the workflow.if
Step to check answer.Defining output parameters. Testing the Automation. Exposing the Automation as a request in the Self-service portal.
A Pack is a collection of Workflows. If you already have a Pack you can open it and skip ahead to creating a new Automation. If you don’t have an existing pack, follow these steps:
Parameter Name | Description | Selection type | Options |
---|---|---|---|
instance_type | The size of the instance. | Single-select | t2.micro (default), t2.medium, t2.large |
reason | Reason for request. Will be sent with the approval request if the user selects a non default instance size. | String |
You have created an Automation with Input Parameters. Proceed to create the Steps of your Automation as described in the following section.
if
Step to control the workflowSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{inputs.instance_type}} | Not equals | t2.micro |
If the instance type is not t2.mirco. If the condition is met (need escalation), go to Step 2. If the condition is not met (instance type is t2.micro, thus no need for escalation), go to Step 5.
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 Asks questions via Slack 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.
Click on Action #2 to change the name of the action to Asking a question via Slack.
Enter the condition using the variable picker.
Parameter | Description | Example |
---|---|---|
Approver | Receipts emails address or channel name. | Random |
Question | Question to be answered. | *{{metadata.user_email}} is trying to use {{inputs.instance_type}}. Reason: {{inputs.reason}} |
Answers | Commas separating possible answers | Yes, No |
if
Step to check answerSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{steps.S2.output}} | Equals | No |
If the condition is met (answer is no), go to Step 4. If the condition is not met (answer is yes), go to Step 5.
Click and type Abort Step. No input parameters are required.
The commands calculates terraform plan and stores it in out.txt file, then it shows this plan in a json format.
if
Step to control the workflowSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{any(steps.S7.output.resource_changes, {'delete' in #.change.actions})}} | equals | true |
If the condition is met (need escalation), go to Step 10. If the condition is not met (no deleted resources, thus no need for escalation), go to Step 13.
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 Asks questions via Slack 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.
Click on Action #10 to change the name of the action to Asking a question via Slack.
Enter the condition using the variable picker.
Parameter | Description | Example |
---|---|---|
To | Receipts emails address or channel name. | Random |
Question | Question to be answered. | Apply the following changes: {{steps.S7.output}} For more details, refer to expression language. |
Answers | Commas separating possible answers | Yes, No |
if
Step to check answerSelect if
Step using the icon:
Left value | Operator | Right value |
---|---|---|
{{steps.S2.output}} | Equals | No |
If the condition is met (answer is no), go to Step 12. If the condition is not met (answer is yes), go to Step 13.
Click and type Abort Step. No input parameters are required.
You can test your Automation before you publish it.
Expose the Automation as a Request to make it available in the Self-service portal of other members.
The Self-service portal is found on the top left of your screen, click > Portal. All Workflows exposed to you are presented. Users with access to this request can use the Automation by filling in the input parameters and running the Request. The creator will get notified every new run of the Automation for auditing purposes.