Alexa Skill for AWS Cloud Storage
Often, I find myself looking for general information about the AWS services and resources deployed within my AWS account. For example, I regularly want to know if there are any public S3 buckets in my account, or how many EBS volumes have been provisioned. I know I can get this information in some different ways. I could run a [AWS CLI] (https://aws.amazon.com/cli/) command on my laptop, I could create a [custom script] (https://github.com/boto/boto3), or I could just log into the AWS Management Console. All of these methods would work no problem, but in my opinion, they all seem like overkill when I just need some basic information.
What I needed was a low-friction solution, which allowed me to quickly get the information I needed without much (if any) real effort.
If you know me, you know I’m a massive fan of Voice Computing. The interface - simple voice commands - means you’re able to get the information you need without any complexity. This simplicity means it’s the perfect solution for my situation. I can build an Alexa skill, and then just ask for the information I want,
“Alexa, ask Gordo how many public buckets are in the account.”
It is that easy, here’s what I ended up creating.
Let’s go through the different AWS services I used to build the solution.
AWS Step Functions
The Step Function is where most of the work happens. I decided to use Step Functions here to keep my Lambda Function(s) as simple as possible. When I first started the project, I used one Lambda Function, but very quickly the function became quite large and difficult to manage.
By breaking the single Lambda Function into several smaller Functions and tying them together with Step Functions, it’s a far easier process to manage.
One other thing - we’re starting the Step Function via another Lambda Function. The stand-alone Lambda function is invoked several times a day using CloudWatch events.
Amazon DynamoDB
Lambda functions are stateless, so I needed a way to store information about the services I’m polling - for now, just Simple Storage Services (S3) and Elastic Block Storage (EBS). The data I’m storing is non-relational, and I need a flexible database schema because I’m planning on saving a variable number of attributes depending on the AWS Service. A NoSQL database like DynamoDB gives me the flexibility I need, and it’s a very cost-effective solution.
The final stage of the Step Function is to take the different service attributes and put them into DynamoDB as individual items.
AWS Lambda
The Alexa skill leverages an AWS Lambda function in my AWS account. The Lambda function pulls information from the DynamoDB table I mentioned earlier and builds the required response for Alexa.
Amazon Alexa
Finally, our voice interface. By using the Alexa Developer console, we’re able to create our skill and associate it with the Lambda function.
What’s Next?
It’s essential to have a clear understanding of the security of your AWS account. With that in mind, I’m going to work on adding Identity and Access Management (IAM) into the Alexa skill next.