Delete EC2 Instance via AWS CLI

Abishek KafleAbishek Kafle
1 min read

Table of contents

Tasks

  • Using AWS CLI, delete an EC2 instance named nautilus-ec2 present in the us-east-1 region.

  • Before submitting your task, make sure the instance is in the terminated state.

Steps

  1. Get the instance ID and Stop the nautilus-ec2 instance.

     aws ec2 describe-instances --filters "Name=tag:Name,Values=nautilus-ec2" --query "Reservations[*].Instances[*].InstanceId" --output text
    

    • i-04575360679a33d0b
  2. Delete the EC2 Instance

     aws ec2 terminate-instances --instance-ids i-04575360679a33d0b --region us-east-1
    

  3. Verify the instance state is on terminated state

     aws ec2 describe-instances --instance-ids i-04575360679a33d0b --region us-east-1 --query "Reservations[*].Instances[*].State.Name" --output text
    

    #aws #cloudcomputing #happylearning

0
Subscribe to my newsletter

Read articles from Abishek Kafle directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abishek Kafle
Abishek Kafle

Infosec Poet and CAP-certified DevOps/SecOps Engineer, passionate about security, creativity, and continuous learning.