Configuring an Amazon EC2 instance using AWS Systems Manager (SSM) involves several steps. This service allows you to manage your EC2 instances at scale without needing to connect to them directly. Below are the steps to configure an EC2 instance through AWS Systems Manager
- You should have an AWS account.
- You should have one or more EC2 instances launched and running.(use vpc default and In firewall(security group)-allow ssh,http,https traffic from the internet)
- Go to the AWS Management Console.
- Navigate to the Identity and Access Management (IAM) dashboard.
- Create a new IAM role and attach the "AmazonEC2RoleforSSM" policy to it. This policy grants necessary permissions to Systems Manager for EC2 instances.
- Attach this IAM role to your EC2 instance when launching or modify the instance's IAM role.
- SSH into your EC2 instance.
- Download and install the SSM Agent by following the instructions provided in the AWS Systems Manager documentation for your specific operating system. The agent enables communication between the EC2 instance and Systems Manager. (https://docs.aws.amazon.com/systems-manager/latest/userguide/agent-install-al.html)
- sudo yum install -y https://s3.region.amazonaws.com/amazon-ssm-region/latest/linux_amd64/amazon-ssm-agent.rpm
- After installation, ensure that the SSM Agent is running and configured correctly by running the following command on your EC2 instance:
- sudo systemctl status amazon-ssm-agent
The status should indicate that it is active and running.
Now that your EC2 instances are configured with SSM, you can use Systems Manager to perform various tasks, such as running commands or automating tasks:
- In the AWS Systems Manager console, go to "Run Command" and create a new command.
- Select the EC2 instances you want to target.
- Choose the SSM document created in the previous step.
- Configure any parameters or inputs required by the document.
- Start the command execution.
- You can monitor the progress and view the results of the SSM Run Command execution in the AWS Systems Manager console. This allows you to ensure that the desired configuration or automation task was executed successfully.
- If you want to make some changes to the code, click Copy to new.
- change the command.