How to manage your AWS from Slack using Opsidian

Dariusz Dwornikowski
Opsidian
Published in
7 min readNov 14, 2016

In this article I will show you how to install and use Opsidian.ai, a Slack chatbot that is one of the eight finalists of the AWS Serverless Chatbot Competition.

Opsidian helps you monitor and manage your AWS Infrastructure from Slack. In fact, Opsidian is a part of increasingly popular trend, called ChatOps. ChatOps is about bringing your DevOps work to your chats and conversations within a team, e.g. Slack. You can, for example, deploy code, monitor servers, close issues in a bug tracker just by talking to a chatbot, which understands natural language or special commands.

In this post we will create a sample Wordpress installation on AWS with the help of CloudFormation, then we will install Opsidian in a Slack team. We will execute some Opsidian commands and clean up the infrastructure.

Installing Wordpress in the AWS

In order to have something to manage with Opsidian, first we will install a fully featured Wordpress blog.

You can freely skip this step if you already have an AWS infrastructure to play with.

Let’s install Wordpress. We will do it using AWS CloudFormation, and a sample Wordpress template provided by Amazon. The template will deploy instances with Wordpress already installed, create a database and a load balancer that will forward traffic to our blog web servers. We do not need to install anything on the instances, AWS will do it for us. Before all this magic happens, we need to create an SSH key in our AWS account to be used in our template. I will assume we use the eu-west-1 region (Ireland). Feel free to choose your own.

You can create an SSH key in EC2 service by following this link. I have created a key named darek, you should see a similar picture.

Now, we can proceed to CloudFormation and create our stack. Click Create Stack and choose Wordpress blog in the Multi-AZ Section. When you click Next, you will be redirected to the page where you will have to fill in the template’s parameters.

I chose the following parameters. For DBUser and DBPassword I just used wordpressdb. It is not the safest choice but for the sake of this demo it will suffice. I chose the SSH key name from a dropdown menu and decided to spin 2 Web Servers initially. You also need to name the stack, you can choose whatever you like there.

Let’s create the stack, click “Next” until you see the “Create” button. Click “Create” and wait for the stack to be created. This can take some time, since AWS will deploy every resource needed by our WordPress.

After some time the Status will read CREATE_COMPLETE. In the Outputs tab you can see interesting information about the created resources, here you can get the WebsiteURL key, which points to the WordPress installation. You can go there and verify that your Wordpress works and finish the installation by setting up a username and a password for the admin editor.

With that done, let’s install Opsidian to help us manage the newly created AWS resources.

Installing Opsidian.ai

Go to http://opsidian.ai/ and click the Add to Slack button. You will be redirected to a Slack’s page where you can choose your Slack team. Click it to install Opsidian.

Click it to install Opsidian

Now, you have Opsidian.ai installed in your Slack. You can verify it by executing the /ops help command in any channel. But hey ! Opsidian’s installation is not complete just yet. We still need to give it access to our AWS account.

The first message by Opsidian.

The first message by Opsidian.

Opsidian needs a read only IAM role created to access your resources, to make this easy it provides a CloudFormation template, which can create the role for us. Let’s do it by clicking the Launch Stack link in the message above. Assuming we are still logged into our AWS Web Console, we should now be redirected to the CloudFormation stack creation page in the AWS Web Console. Just fill in the parameter called SlackTeamName. It should match your Slack team name ! I will use chatsoft, since that is my Slack team’s name.

Now click Next and wait for your stack to create the role, it should not take long. In the Outputs tab you will see the role’s ID, it starts with arn:aws:iam…

Now go back to your Slack and execute the following command. It will bind your Opsidian bot to the role you have just created.

/ops account add name=MyAccount arn=arn:aws:iam..THE ROLE ID region=eu-west-1

Congratulations! Now your Opsidian.ai installation is complete. Let’s play with it a bit.

Fist let’s see the instances running. Remember, I chose two instances to be created, so after executing /ops ec2 list instanceswe should see something like that:

My WordPress instances

Great news, both of the instances are running. Let’s see some details of the second one.

/ops ec2 show instance i-634e55f4

Neat, we can see that it was created by CloudFormation, just as the tags suggest. But we also have a load balancer, in AWS it is called ELB. Let’s see how things are with it.

/ops elb list balancers

Let’s see some details about this guy, there is a command for that too. It takes a balancer’s name as an argument.

/ops elb show balancer MyWordPre-ElasticL-9IP322PD33T9

Yup, it shows us some more information now. We even can see the DNSName of our ELB, which points to our WordPress blog. Let’s see some information about our database, in AWS the relational database service is called RDS.

/ops rds list instances

There it is, our database. Remember if you do not remember the commands, Opsidian provides help with /ops help, you can also visit the website https://opsidian.ai/commands for a reference. Even better, Opsidian allows you to query using natural language. Just ask.

/ops rds what instances do we have running?

Until now, we have only browsed our resources. A really great feature of Opsidian is the ability to show CloudWatch alarms and their related plots. Let’s go back to our AWS Web Console and create an alarm for the ELB. Go to EC2, Load Balancers section (or click here). In the Monitoring tab, click Create Alarm.Next, choose the values I chose, see the screenshot below for a quick reference.

Now go back to your Slack and execute:

/ops cloudwatch list alarms state OK

And now for the coolest part, let’s see some plots:

/ops cloudwatch plot alarm awselb-MyWordPre-ElasticL-9IP322PD33T9-High-Healthy-Hosts

Isn’t it just cool? You can see the plot right inside Slack. Imagine how helpful this is when working with a team. You all have the same view on how things are going with your AWS resources. And this is what chatops is about.

Clean up

To clean up the resources we have just created with the CloudFormation template, just go the CloudFormation section in your AWS Web Console, choose your WordPress stack and Delete it. AWS will take care of destroying all the resources so they do not cost you any money.

Summing up

I have shown you how to create a fully functional multi AZ Wordpress installation in a way that professional cloud architects do it. Then we have installed Opsidian in a Slack account, used it to get some knowledge on our AWS resources, and set up alarms for our ELB.

Managing your infrastructure from a chat may seem a bit silly at first but when you think about it, it is quite the opposite. First of all you do it in a collaborative way, the whole team can discuss what you ask Opsidian to show. No more situations where one guy has a different window opened on his computer, or is logged into another account. In a world where more and more jobs in IT are remote, Slack becomes the centre and the heart of your team. Secondly, using Opsidian to monitor AWS is just convenient. Text interfaces are natural for a human, we all know how to write, right? You can access Slack fast from your smartphone, computer or tablet, no matter where you are. Opsidian is ever evolving, I am excited to see where it will go.

--

--

Dariusz Dwornikowski
Opsidian

Building products and technology in cloud. Ex VP Engineering at Nordcloud, now CTO at Worksuite.