AWS CLI and SSM

Wondering if anyone knows whether the AWS cli is baked into the SSM client? Looking for a way to send data to an S3 bucket regardless of AMI.

I am testing on an Amazon Linux 2 AMI and the AWS cli appears to be already installed on the instance (not sure if that’s an Amazon Linux 2 thing or if SSM is what is making it able to make the call to the cli - as I am successfully able to run “aws s3 cp /file/to/upload/file.txt s3://*NameOfS3Bucket/*file.txt”.

Like I said, just want to make sure I’m able to do this across all AMIs as we are looking to automate some things. Happy to have a conversation on the side to give more details if necessary. Thanks!

You’re right. The ami has the cli. See if there’s an automation doc from aws which will do raw api calls.

It really depends on how you’re deploying the EC2 instance your AMI is running on and what your constraints are. If you’re deploying an application on the AMI you could run a script that installs the AWS CLI client, or if nothing is deployed to it and it’s part of an Auto Scaling Group (because why not), you can execute code on instance refresh (i.e. when the EC2 instance starts up) as part of the User Data property. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html.

Ya. To that end, cfn init, cloud init have concepts of files, sources, which can pull files for you also..

The RHEL 7 AMI shipped without the CLI, which was a huge nuisance. You can safely assume that the AL2 AMIs will always have the CLI, but you should assume that any other Linux AMI doesn’t until verified otherwise.

The Windows AMIs all ship with the Powershell CLI in place, too.

You might want to consider how you manage and standardize your AMI’s.

We ended up creating a concept of an AMI bakery that uses packer to create EC2 images that we manage for our organization. It installs various required software etc. hardens it, and then shares it out to our Organizational Units. Then you could enforce based of AMI, so that the images being spun up are ones blessed by you (which would have awscli pre-installed).