Automate the triviality in AWS using unSkript

Introduction

This week, AWS is celebrating all that is AWS at their re:Invent conference in Las Vegas. Here at unSkript, we are celebrating all that is AWS by highlighting how to automate common AWS tasks with our xRunBooks. In our first series (Part 1Part 2Part 3) , we built a xRunBook that creates an IAM user, applied a Managed access policy to the user, finally removing the user .

Today we will look at engineering productivity!

In the cloud world, engineers enabled with IaC workflows, spin up resources for building products. Post work, they end up not cleaning the cloud workspace which causes $$$ as everything is metered. Internally to any company, engineering (considered as a cost center) always on a hunt to cut down inefficiencies, wants to bring in policies, processes, and automation.

With Cloud Platforms in the picture, engineering costs accelerate. This is where a platform like unSkript, helps in automating triviality.

In this post, we will automate the most important problem any CTO, CIO face day-to-day. Managing infrastructure spend! We will spin up a EC2 instance from an AMI, and then stop the untagged instance.

Getting started

To begin, you’ll need to create a free account in the unSkript Sandbox. There is a 3–4 minute walkthrough of the features that you’ll need to go through (if you haven’t already) that will highlight some of the features of unSkript.

Once you’ve completed the walkthrough, we’ll import the existing xRunBook into your account.

  1. Click xRunBooks from the top menu, and click the Create button on the top right corner. Create the xRunBook by filling the details.

2. Click on the Editor button

3. Select actions needed by searching in the actions sidebar. For example, we need to spin up a EC2 instance from AMI.

Drag and drop the actions needed onto the xRunbook Canvas.

4. Configure the parameters needed for the actions namely, AWS Cloud region, AMI Id, and instance ID.

Note: AWS Credentials are configured in this RunBook by default, to learn more about configuring your credentials, please refer to Part 1 of the initial blog series.

5. Finally, execute the xRunbook actions individually to see the results.

Note: Do not forget to configure or put out the instance id to terminate the untagged EC2 instance while running the last action.

A fully completed xRunbook with all the actions should look like below.

Actions

Launch AWS EC2 Instance from an AMI

This action takes in a AMI Identifier as an input, spins up a EC2 instance. We can see a JSON output with the instance id, other EC2 specific configuration details.

Filter AWS Untagged EC2 Instances

All untagged EC2 instances will be filter after running this action. It takes AWS Region (say us-west-1) as an input.

An Instance Id array will be returned post the execution of action as an output.

Terminate AWS Instances

This action takes in the Instance Id as the input from the previous action. The EC2 instance related to the particular Instance Id will be terminated.

Conclusion

In a crux, the day to day productivity of an engineer improved as we automate more trivial but also important cost saving tasks for the organization. Remember, xRunBooks executions can be sent for approvals, executions are audited for further checks.

Lastly, one can trigger these xRunBooks directly from the unSkript’s main console, without looking at the details of the xRunbook.

Interested in learning more about how unSkript can help you build internal tooling for your team? Check out our free trial, star our GitHub repository of xRunBooks and Actions, or join our Slack Community!

Share your thoughts