Search code examples
amazon-web-servicesubuntuamazon-ec2ssm

aws ssm send command not working in Ubuntu servers


I just started exploring aws system manager feature.

I am using python 3.6 and boto3 to test ssm.

I have created the Ubuntu server EC2(t2 micro) and assigned the IAM role with policy "AmazonEC2RoleforSSM", which as per my knowledge should allow running ssm send command on that EC2. But, instead I get below error:

botocore.errorfactory.InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation:

I even tried to check the output of:

ssm.describe_instance_information()['InstanceInformationList'])

It doesn't have the instance Id I created, which pretty much tells the story why I am getting that error. But, to my knowledge if I assign the IAM role with above mentioned policy it should show up in the list.

Strangely when I try to do above setup with Amazon Linux AMI server and run ssm everything looks good.

any idea why ssm not working in ubuntu server? I am missing something?


Solution

  • But, to my knowledge if I assign the IAM role with above mentioned policy it should show up in the list.

    No, there's much more to it than that. You need to install the AWS SSM agent on each server you want to manage. The reason it is working for you with Amazon Linux is that the latest version of Amazon Linux has the SSM agent pre-installed.