VM::EC...Subnet(3pm)

πŸ“¦
version 1.28 Β· 7 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– VM::EC2::VPC::Subnet β€” the perl manual page, bestie edition πŸ’–

okay so. you're reading VM::EC2::VPC::Subnet(3pm) β€” that's a User Contributed Perl Documentation page, section 3pm, and it's all about the object that represents a VPC subnet in Amazon EC2. pull up a chair, we're doing cloud networking but make it cute ✨


🌸 NAME 🌸

VM::EC2::VPC::Subnet β€” literally just: a VPC subnet. that's the whole vibe. a subnet, but as a Perl object, and it's serving πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

here's how you'd actually use it, no cap:

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";
}

see? spin up an EC2 handle, make a VPC, make a subnet inside it, then loop over everything describe_subnets hands back and print the juicy bits. iconic. πŸ¦‹


🫢 DESCRIPTION 🫢

so this object is the one that supports the EC2 Virtual Private Cloud subnet interface. that's its whole job, and it's doing great at it ngl.

also β€” and this part matters β€” there's a bunch of methods that every VM::EC2 object shares, and those live over in VM::EC2::Generic. go read that one too, bestie, this page isn't the whole story πŸ‘‘


✨ METHODS ✨

the object methods (the main cast)

these are the ones baked right into the object, fr fr:

  • subnetId β€” the ID of the subnet. its government name πŸͺͺ
  • state β€” the current state of the subnet, and it's either "pending" or "available". those are the only two options, don't @ me
  • vpcId β€” the ID of the VPC the subnet is in. who's your parent 🍼
  • cidrBlock β€” the CIDR block assigned to the subnet
  • availableIpAddressCount β€” the number of unused IP addresses in the subnet. the headcount of available spots πŸ“
  • 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

tagging interface

this class supports the VM::EC2 tagging interface. for the details on that, go check out VM::EC2::Generic. iykyk πŸ’œ

the convenience methods (the bonus tracks)

and in addition, this object supports these 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 successful
  • disassociate_route_table($table) β€” removes the association of a route table with this subnet. > heads up: this 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

🌈 STRING OVERLOADING 🌈

the way this object is so versatile β€” when you use it in a string context, it gets interpolated as the subnet ID. so you can just slap it in a string and it knows what to do. main character energy, genuinely πŸ’…βœ¨


πŸ‘€ SEE ALSO πŸ‘€

  • VM::EC2
  • VM::EC2::Generic

go read those, they're the extended universe 🌸


πŸ’– AUTHOR πŸ’–

Lincoln Stein <lincoln.stein@gmail.com>.

Copyright (c) 2012 Ontario Institute for Cancer Research

This package and its accompanying libraries is free software; you can redistribute it and/or modify it under the terms of the GPL (either version 1, or at your option, any later version) or the Artistic License 2.0. Refer to LICENSE for the full license text. In addition, please see DISCLAIMER.txt for disclaimers of warranty.


and that's the whole page, bestie!! πŸŽ€ this was perl v5.38.2, dated 2024-08-10, and the page is VM::EC...Subnet(3pm) β€” slay, go make some subnets, and remember: no cap, only CIDR blocks πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from