I have an EC2 instance that runs out of an AMI (Ubuntu-based) built by our team. The AMI doesn’t have either “aws” cli or “ssm” agent preinstalled, and they will NOT do it as part of their build.
I need to launch this instance in a Private Subnet, where it has rules only to talk to VPC Endpoints. There is no NAT gateway or IGW attached to this VPC.
So I have uploaded the SSM binary (.deb) to S3 bucket, so the EC2 instance can pull that using S3 VPC Endpoint. But the catch is, I don’t have “aws” cli to run the aws s3 cp s3uri <localpath> --endpoint-url <url> command.
Do you have any ideas on how I can install an SSM agent on this EC2 instance?
PS: I have a total of 15 such AMIs, and I need to launch one instance for each AMI.
Build a new AMI on top of theirs using Packer, run the build in a public subnet?
Alternatively, I guess you could make the deb file public and call the S3 api directly through http. Or generate a signed request yourself but that’s a bit more effort than at least I would consider worth it.
Can you launch an instance running Amazon Linux? This image already has the CLI and SSM agent pre-installed.
If you can, then you can use this as a jump station. Use this instance to copy the installer from S3 and scp that over to your Ubuntu instance. Do the same for the same agent.
Once you have the installers on the machine, you should be able to install the CLI and agent. Make sure you have the right permissions attached to the IAM role to ensure you can access the SSM service.
In addition, since you don’t have internet connectivity in your vpc, you will need an interface endpoint to the SSM service to actually use the service.
You can use the user-data of the EC2 instance to run a script when the instance is created. The script can install aws cli, ssm and do whatever you want to the instance.
Thanks, everyone, for giving some ideas; what I noticed is when I converted the OVA to AMI using aws ec2 import-image, I saw AWS added the SSM agent during the AMI creation process. I was not expecting that.
Out of 11 AMIs, 10 are communicating via SSM, but one is not, and I am checking what is wrong with it. (At this time, I am trying to recreate the AMI for that one with the hope it will work).
I think you need to fight for at least AWS CLI, technically you can pull the files from S3 without the client using your VPC endpoint, but you will have to manage the keys and it is probably worse solution than just installing the CLI.
Other option could be to have a EBS volume to attach with user-data and have the required tools there and detach it once your are done, but its more and more complex stuff just to avoid installing the CLI.