How To add EC2 instance to AWS System Manager-DecodingDevOps
How To add EC2 instance to AWS System Manager-DecodingDevOps
aws system manger is set of fully managed aws service and capabilities that enable automated configuration and ongoing management of systems at scale across all your windows and Linux ec2 instances. Sometimes you will get requirement like, install some software's or run commands or executing some shell scripts, or update the packages on multiple ec2 instances in aws, Using aws system manager we can do all these things at once. Aws system manager provides you flexible and easy to use automation focused approach for managing your aws ec2 instances. In this post we are going to see how to add ec2 instance to aws system manager step by step.
To add ec2 instance to aws system manager
we have to do two things those are
- create a role with aws ssm policy and add this role to ec2 instance.
- install ssm agent on ec2 instance.
by doing these two things you can add ec2 instance to aws system manger and you can find the ec2 instances in systems manager console.
Create Role with AWS SSM Policy
Login to to your aws console and go to IAM and click on create role. Select EC2 service that will use this role.
attach AmazonSSMFullAccess policy to this role and create the role.
give a name to your role and create the role
Now we have successfully created the ssm role. Now we need to attach this role to every ec2 instance which you are going to lunch.
Add SSM role To Ec2 Instance
launch ec2 instance and when you are launching ec2 instance attach ssm role which you created in previous steps and add below script in user data.
Install SSM Agent on Redhat
Using below commands you can install ssm agent on redhat server or rhel machines.
#!/bin/bash sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm sudo systemctl enable amazon-ssm-agent sudo systemctl start amazon-ssm-agent
Thats it we have successfully installed ssm agnet on rhel or redhat server. Now you can see ec2 instance in aws system manager and you can connect ec2 instance with aws session manager.
Install SSM Agent on Amzon Linux
By adding below commands in userdata, you can install aws ssm agent on amazon linux machines.
#!/bin/bash sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm sudo start amazon-ssm-agent sudo systemctl enable amazon-ssm-agent
Install SSM Agent on Ubuntu 16.04
By adding below commands in userdata, you can install aws ssm agent on ubuntu 16.04
#!/bin/bash mkdir /tmp/ssm cd /tmp/ssm wget https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/debian_amd64/amazon-ssm-agent.deb sudo dpkg -i amazon-ssm-agent.deb sudo start amazon-ssm-agent sudo systemctl enable amazon-ssm-agent
Install SSM Agent on Centos 7
By adding below commands in userdata, you can install aws ssm agent on centos 7
#!/bin/bash sudo yum install -y https://s3.amazonaws.com/ec2-downloads-windows/SSMAgent/latest/linux_amd64/amazon-ssm-agent.rpm sudo systemctl enable amazon-ssm-agent sudo systemctl start amazon-ssm-agent
- add ec2 instance to aws system manager
- ec2 instance not appearing in system manager
- ssm agnet not installing.