- Welcome.
In this demonstration, we are going to use SSM Run Command,
using the AWS CLI, to perform a couple
of fleetwide operations that any company might choose to do.
So we're gonna start off by recognizing
that we have a couple of EC2 instances.
Both of these have the appropriate permissions
and the Systems Manager Agent installed.
And so from there, we can go straight to our terminal
to perform work.
And our first operation is to issue a command
that will install the AWS CLI v2 on the instance
or upgrade it to the latest version,
if it's already installed.
And for that, we have to determine the CPU architecture
of the instance itself, whether it is ARM64 or x86.
If we go back to the EC2 dashboard,
we'll see that these are t4g micros.
The G indicates gravitron, which means that they are ARM64.
And so that is the script we're gonna run.
Let's take a look at it.
It's a relatively straightforward script.
Now, I have provided an option for deploying this
in multiple regions that all you would have
to do is graviton that line and then comment out
the following one.
But since we only have instances in us-east-1,
that's the only region that we need to use.
Then, we are going to loop through each
of those regions defined by that variable,
and we're gonna issue SSM Run Command as an operation,
which is AWS SSM send-command.
And then, we provide a document name that,
in this case, is AWSRunShellScript.
Document version is one.
And this next piece is important, our targets.
We are going to target everything that has a tag
with a key value of name, and that's it.
As long as it has a name tag, regardless of the value,
that's what we're going to execute this on.
And then, we have everything else.
We have the working directory.
We have execution time out.
And then we have the actual commands.
And this is taken mostly from the AWS Documentation.
Installing unzip, just in case.
Executing a curl to download the actual CLI zip file.
Unzipping it, and then doing a sudo./AWSinstall.
And we have our timeout on individual instances
of 600 seconds, max concurrency of 50, max errors of 50%,
and then we just specify our region.
So with that, let's go ahead and execute the script.
The output is going to be the equivalent
of having issued a described command from SSM Run Command.
And you can see it gives you the command ID
and all the same information that we provided,
along with a bunch of defaults.
And so at this point, we could switch back to the console,
go to SSM Run Command, and view the results.
And what's interesting is it says no commands are executing.
Why is that?
SSM Agent issues a long poll
against the service API endpoint.
That means it is constantly looking for work.
When you execute that command, it is taken care of
almost immediately by the clients.
So now, if we go to command history, we can see here
the most recent command that was run is successful
on two targets.
So we can then click on the command ID,
and we can dig a little deeper.
We'll pick an instance as an example, and we can see
that we have a standard error just says is really
from the curl command.
And then the output will tell us
that it's inflated all of those executables
and documents and bits and pieces of the AWS CLI.
And if we scroll all the way down to the bottom,
we'll see that it completed successfully.
And that completes this demonstration.