Getting the ID from the default VPC¶
Feature overview¶
🚀 Method | get_default_vpc_id() |
📄 Description | A method that enables users to get the ID of the account's default VPC |
📦 Acessible from | cloudgeass.aws.ec2.EC2Client |
Feature demo¶
The EC2Client get_default_vpc_id()
method is built from a boto3 ec2 client method called describe_vpcs(). It takes the method's response and gets the VPC ID if the response key 'IsDefault' is true. Let's see this in practice.
# Importing the client class
from cloudgeass.aws.ec2 import EC2Client
# Creating a class instance
ec2 = EC2Client()
# Getting the ID from the default VPC
vpc_id = ec2.get_default_vpc_id()