VM::EC2::VPC::Subnet -- A VPC subnet
Contents
Description
This object supports the EC2 Virtual Private Cloud subnet interface. Please see VM::EC2::Generic for
methods shared by all VM::EC2 objects.
Methods
These object methods are supported:
subnetId -- the ID of the subnet
state -- The current state of the subnet, either "pending" or "available"
vpcId -- The ID of the VPC the subnet is in.
cidrBlock -- The CIDR block assigned to the subnet.
availableIpAddressCount -- The number of unused IP addresses in the subnet.
availableZone -- This subnet's availability zone.
defaultForAz -- Indicates if this is the default subnet for the Availability Zone
mapPublicIpOnLaunch -- Indicates if instances launched in this subnet automatically receive a
public IP address
This class supports the VM::EC2 tagging interface. See VM::EC2::Generic for information.
In addition, this object supports the following convenience methods:
vpc() -- Return the associated VM::EC2::VPC object.
zone() -- Return the associated VM::EC2::AvailabilityZone object.
refresh() -- Refreshes the object from its current state in EC2.
current_state() -- Refreshes the object and returns its current state.
create_route_table() -- Create a new route table, associates it with this subnet, and
returns the corresponding VM::EC2::VPC::RouteTable
object.
associate_route_table($table)
-- Associates a route table with this subnet, returning true if
sucessful.
disassociate_route_table($table)
-- Removes the association of a route table with this subnet. Produces
a fatal error if $table is not associated with the subnet. Returns true
on success.
associate_network_acl($network_acl_id)
-- Associates a network ACL with this subnet, returning the new
association ID on success.
disassociate_network_acl()
-- Removes the association of a network ACL with this subnet. The subnet
will then be associated with the default network ACL. Returns the
the association ID.
Name
VM::EC2::VPC::Subnet -- A VPC subnet
See Also
VM::EC2 VM::EC2::Generic
String Overloading
When used in a string context, this object will be interpolated as the subnet ID.
Synopsis
use VM::EC2;
my $ec2 = VM::EC2->new(...);
my $vpc = $ec2->create_vpc('10.0.0.0/16');
my $subnet = $vpc->create_subnet('10.0.0.0/24') or die $vpc->error_str;
@subnets = $ec2->describe_subnets;
for my $sn (@subnets) {
print $sn->subnetId,"\n",
$sn->state,"\n",
$sn->vpcId,"\n",
$sn->cidrBlock,"\n",
$sn->availableIpAddressCount,"\n",
$sn->availabilityZone,"\n";
}
