Skip to main content
Amazon EC2 (Elastic Compute Cloud) is a service that provides secure, resizable compute capacity in the cloud. It allows you to launch virtual servers (instances), manage storage volumes, security groups, and networking configurations. With the EC2 handler, you can programmatically retrieve and manage EC2 resources such as instances, volumes, AMIs, snapshots, and more.

Example

To create the AWSEC2Handler object with AWS credentials. The AWSEC2Handler connects to AWS EC2 using access credentials (access key, secret key) and a region name. It enables seamless interaction with EC2 for retrieving and managing compute resources.
ec2_handler_test.py
Get Instances:
The get_instances method fetches all EC2 instances.
Get Security Groups:
The get_security_groups method fetches all security groups.
Get Volumes:
The get_volumes method fetches all EBS volumes.
Get AMIs:
The get_amis method fetches all AMIs owned by the account.
Get Snapshots:
The get_snapshots method fetches all snapshots owned by the account.
Get Key Pairs:
The get_key_pairs method fetches all key pairs.
Get Network Interfaces:
The get_network_interfaces method fetches all network interfaces.
Collect All EC2 Resources:
The collect_all_ec2 method fetches all EC2 resources in parallel.