Member-only story
Managing EC2 Instances with AWS Systems Manager
3 min readMar 31, 2024
To manage EC2 instances using AWS Systems Manager (SSM), it’s essential to first ensure your instances are correctly configured to use SSM. This includes attaching the appropriate IAM role to the instances and ensuring the Systems Manager agent is installed and running on your EC2 instances. After setup, you can use various features of Systems Manager to manage your instances.
Initial Steps
- Check the SSM Agent: Ensure the SSM agent is installed and running on your EC2 instances. By default, Amazon Linux 2 instances and some versions of Ubuntu Server come with the agent pre-installed.
- Configure IAM Role: Attach an IAM role to your EC2 instances that grants the necessary permissions for Systems Manager to operate. The managed policy
AmazonSSMManagedInstanceCore
provides the required permissions.
aws iam create-role --role-name SSMRoleForEC2 --assume-role-policy-document file://TrustPolicyForEC2.json
aws iam attach-role-policy --role-name SSMRoleForEC2 --policy-arn arn:aws:iam::aws:policy/service-role/AmazonSSMManagedInstanceCore
aws ec2 associate-iam-instance-profile --instance-id <YOUR_INSTANCE_ID> --iam-instance-profile Name=SSMRoleForEC2
Replace <YOUR_INSTANCE_ID>
with the ID of your EC2 instance.