Using Console
Using CLI
instance_id
with the ID of the instance that needs to be stopped. This command will stop the instance.
image-id
, instance-type
, key-name
, security-group-ids
, and subnet-id
with the same configuration as the stopped instance. This command will launch a new instance.
instance_id
with the ID of the stopped instance. This command will terminate the old instance.
Using Python
boto3
module.boto3.Session()
method.boto3.client()
method to connect to the EC2 service.describe_instances()
method to get a list of all running instances.terminate_instances()
method to terminate them.stop_instances()
method to stop the instances instead of terminating them.describe_instances()
method to target specific instances based on tags or other attributes.