In our previous tutorials about managing your Ubuntu servers with AWS SSM, we learned how to open shell sessions without having to do SSH logins and how to update your instances in an automated and scalable way using SSM Run Command.
In this tutorial, as the third part of SSM basics on Ubuntu, we will learn how to run custom automation scripts, using SSM Documents and Run Command in AWS Systems Manager.
Our first SSM Document will be for installing packages from the Ubuntu repositories. If you are not new to this, you will know that this is as simple as updating the cached package list and then installing the desired packages.
If we were on the console, the commands would be:
sudo apt update
sudo apt install -y mypackage
This very simple example will help you to install packages massively in your fleet avoiding tedious and error prone work, while helping you to understand the SSM Document basics, allowing you to write your own scripts.
What you’ll need
- An AWS account
- Understanding of IAM roles for EC2 instances
- Understanding SSM basic functionalities: Make sure you have followed the previous two tutorials, since this can only be applied to servers that have become “SSM managed nodes” (in other words, you need to know how to add the IAM SSM policy to your instance profile or role).
- Some Ubuntu Servers running
What you’ll learn
- What are SSM Documents
- How to create your own SSM Document with user parameters
- How to run SSM Documents with RunCommand