How to execute actions listed under Post using AWS CLI
We've followed AWS Console Steps to use AWS Systems Manager Automation Document - "AWSSupport-ExecuteEC2Rescue" to fix SSH issue on a Linux EC2 Instance.
To check console steps , please click below link
How to use AWS Systems Manager Automation Document - "AWSSupport-ExecuteEC2Rescue" to fix SSH issue on a Linux EC2 Instance
Now, I will be explaining you how we can achieve this using AWS CLI commands using simple steps:
Make sure you have AWS CLI setup and you've enough permissions to use SSM to execute these documents.
If you have admin privileges , it will be great !
Steps Using AWS CLI:
• Running the Automation Document for an unreachable Instance (i-xxxxxxxxx) :
# aws ssm start-automation-execution --document-name "AWSSupport-ExecuteEC2Rescue" --document-version "\$DEFAULT" --parameters '{"UnreachableInstanceId":["i-xxxxxxxxxxxxx"],"EC2RescueInstanceType":["t2.small"],"SubnetId":["CreateNewVPC"]}' --region eu-west-2
{
**"AutomationExecutionId": "43f1918f-b0bb-4a25-xxxxxxxxxxxxx"**
}
• You can also see the automation scheduled (using Console)
• Checking the Automation progress / Status:
# aws ssm get-automation-execution --automation-execution-id "43f1918f-b0bb-4a25-xxxxxxxxxxxxxxxx" --output text --query "AutomationExecution.AutomationExecutionStatus" --region eu-west-2
**InProgress**
• Let’s wait for few mins to get this completed and we can check the status again:
# aws ssm get-automation-execution --automation-execution-id "43f1918f-b0bb-4a25-xxxxxxxxxxxxxx" --output text --query "AutomationExecution.AutomationExecutionStatus" --region eu-west-2
**Success**
• You can also verify this (using Console)
• After the Status is returned as “Success”, Let’s try to SSH to the Instance again: (Success)
# ssh -i "eu-west-2_key_pair.pem" ec2-user@ec2-xxxxxxxxx.eu-west-2.compute.amazonaws.com
Conclusion
AWSSupport-ExecuteEC2Rescue is a new Automation document that automates all the steps required to fix common issues on your unreachable Windows & Linux instance using respective EC2Rescue for Linux & EC2Rescue for Windows tool tools, which is a framework for executing diagnostic and troubleshooting modules for analyzing and remediating issues.
Overall, It will save a lot of time which is being invested with manual process of detach, attach volume and further steps to troubleshoot issues. This document does all the steps for you in an automated way in just few minutes.
Tip
With the integration between CloudWatch Events and Systems Manager
Automation, you can run AWSSupport-ExecuteEC2Rescue automatically in
response to an event in your infrastructure.
Thanks for reading.
Any feedback, please write it to me here in comments..
Also, 🤝🤗You can connect with me🤝🤗
Top comments (0)