Skip to main content

Command Palette

Search for a command to run...

Delete EC2 Instance via AWS CLI

AWS CLI Commands for Deleting EC2 Instances

Published
1 min read
Delete EC2 Instance via AWS CLI
A

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

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

Cloud Platforms

Part 12 of 48

This series covers cloud platforms (AWS, Azure, GCP, OCI), including certifications, labs, issues, solutions, and billing. We'll also explore on-premises solutions and hybrid cloud environments.

Up next

Modify EC2 Instance Type via AWS CLI

Change EC2 Instance Type Using AWS CLI Commands