Shi
CI/CD/DevOps
Published in
Jun 19, 2020

Using AWS SSO CLI to launch and stop EC2

login to aws sso cli

aws sso login — profile UserAdminAccess-01111111

start the EC2 remotely

aws ec2 start-instances — instance-ids i-028b3329c7539e700 — profile UserAdminAccess-01111111

wait for the EC2 instance to be ok

aws ec2 wait instance-status-ok — instance-ids i-028b3329c7539e700 — profile UserAdminAccess-01111111

stop the EC2 remotely

$ aws ec2 stop-instances — instance-ids i-028b3329c7539e700 — profile UserAdminAccess-01111111{
"StoppingInstances": [
{
"CurrentState": {
"Code": 64,
"Name": "stopping"
},
"InstanceId": "i-01111111",
"PreviousState": {
"Code": 16,
"Name": "running"
}
}
]
}

wait for the EC2 instance to be stopped

aws ec2 wait instance-status-ok — instance-ids i-028b3329c7539e700 — profile UserAdminAccess-01111111

--

--

Shi
CI/CD/DevOps

I am a coder/engineer/application security specialist. I like to play around with language and tools; I have strong interest in efficiency improvement.