EC2 Handler
The AWSEC2Handler
class provides an easy and asynchronous way to interact with Amazon EC2
services using the boto3
library. It allows you to securely connect to your AWS account using either provided credentials or environment
variables. Once connected, the handler can retrieve information about your EC2 instances, specifically those
that are in a running or stopped state. By leveraging asynchronous execution, it ensures that fetching data
from AWS does not block other operations in your application. This makes it a useful component for cloud-based
tools or systems that need to monitor or manage EC2 instances efficiently and in real-time.
Get Instances:
This module collects detailed information about EC2 instances, including their current state, instance type, AMI ID, tags, security groups, and IP addresses. It’s useful for monitoring and managing your AWS infrastructure.
Security GroupS:
This method tests the ability to fetch security group details from EC2 using the AWSEC2Handler. It runs asynchronously and ensures that the handler correctly retrieves information such as group names, IDs, and associated rules.
Volumes:
This method tests the retrieval of EC2 volume details using the AWSEC2Handler. It runs asynchronously and verifies that information such as volume IDs, sizes, states, and attachment details is correctly fetched.
Amis:
This method tests the retrieval of EC2 AMI (Amazon Machine Image) details using the AWSEC2Handler. It runs asynchronously and verifies that information such as AMI IDs, names, and creation dates is correctly fetched.
Snapshots:
This method tests the retrieval of EC2 snapshot details using the AWSEC2Handler. It runs asynchronously and ensures that data such as snapshot IDs, associated volumes, sizes, and creation times is correctly fetched.
Key Pairs:
This method tests the retrieval of EC2 key pair details using the AWSEC2Handler. It runs asynchronously and verifies that information such as key names and fingerprints is correctly fetched.
Network Interfaces:
This method tests the retrieval of EC2 network interface details using the AWSEC2Handler. It runs asynchronously and ensures that data such as interface IDs, statuses, IP addresses, and attachment information is correctly fetched.
Collect All:
This method tests the comprehensive collection of all EC2-related resources using the AWSEC2Handler. It runs asynchronously and verifies that instance details, volumes, snapshots, AMIs, security groups, key pairs, and network interfaces are all fetched correctly.