VM::EC...:subnet(3pm)
VM::EC2::REST::subnet π
okay bestie, welcome to the page where we manage subnet objects and the routing among them β¨ (it's VM::EC2::REST::subnet, in case the tab title didn't already give it away π)
β¨ SYNOPSIS β¨
use VM::EC2 ':vpc';
π¦ METHODS π¦
So these methods manage subnet objects and the routing between them. A VPC can have one subnet or a whole gaggle of them, and the routing rules are literally the vibe check that decides whether your subnet:
- has access to the internet (public π ),
- is entirely private (private π),
- or is connected to a customer gateway device to form a Virtual Private Network (VPN), where your home network's address space gets extended into the Amazon VPC. π§
Every single instance in a VPC lives in one subnet or another β no exceptions, no cap. Subnets can be public or private, and they're organized in a star topology with a logical router sitting in the middle like the main character. π
Even though you can call all these methods from VM::EC2 objects, ngl, a bunch of them are way more convenient from the VM::EC2::VPC object family π«Ά. That's because it lets the steps that typically follow each other β like creating a route table and associating it with a subnet β just happen automatically. Obsessed.
Like, check this: this series of calls creates a VPC with a single subnet, creates an Internet gateway attached to the VPC, associates a new route table with the subnet, and then creates a default route from the subnet to the Internet gateway. Slay.
$vpc = $ec2->create_vpc('10.0.0.0/16') or die $ec2->error_str;
$subnet1 = $vpc->create_subnet('10.0.0.0/24') or die $vpc->error_str;
$gateway = $vpc->create_internet_gateway or die $vpc->error_str;
$routeTbl = $subnet->create_route_table or die $vpc->error_str;
$routeTbl->create_route('0.0.0.0/0' => $gateway) or die $vpc->error_str;
Implemented:
CreateSubnetDeleteSubnetDescribeSubnets
Unimplemented:
(none)
$subnet = $ec2->create_subnet(-vpc_id=>$id,-cidr_block=>$block) πΈ
This one creates a brand new subnet inside the given VPC. You pass it a VPC object or a VPC ID, plus a CIDR block string. If it works, the method hands you back a VM::EC2::VPC::Subnet object. iconic.
Required arguments:
-vpc_idβ a VPC ID or a previously-createdVM::EC2::VPCobject.-cidr_blockβ a CIDR block string in the form"xx.xx.xx.xx/xx". Heads up bestie: the CIDR address must be within the CIDR block previously assigned to the VPC, and it must not overlap other subnets in the VPC. no pressure π
Optional arguments:
-availability_zoneβ the availability zone for the instances launched within this instance (yes, it really says it like that π), either an availability zone name, or aVM::EC2::AvailabilityZoneobject. If you don't specify it, then AWS chooses a zone for you automatically. let the algorithm cook π
$success = $ec2->delete_subnet($subnet_id)
$success = $ec2->delete_subnet(-subnet_id=>$id)
Deletes the indicated subnet, periodt. You can call it with a single argument that's just the subnet ID, or use the named argument form with the argument -subnet_id. your choice, queen β¨
@subnets = $ec2->describe_subnets(@subnet_ids)
@subnets = $ec2->describe_subnets(\%filters)
@subnets = $ec2->describe_subnets(-subnet_id=>$id, -filter => \%filters)
This returns a list of VM::EC2::VPC::Subnet objects. Called with no arguments, it returns all Subnets (not filtered by VPC Id, so likeβ¦ everything π). Pass a list of subnet IDs or a filter hashref if you want to restrict the search. vibe check your results, basically.
Optional arguments:
-subnet_idβ scalar or arrayref of subnet IDs.-filterβ hashref of filters.
Available filters are described at http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html β go read the docs, iykyk π¦
$success = $ec2->modify_subnet_attribute(-subnet_id => $sub_id, -map_public_ip_on_launch => $boolean)
Modifies a subnet attribute. little glow-up for your subnet π
Required arguments:
-subnet_idβ the ID of the subnet to modify.-map_public_ip_on_launchβ modifies the public IP addressing behavior for the subnet. Specifytrueto indicate that instances launched into the specified subnet should be assigned a public IP address. If set totrue, the instance receives a public IP address only if the instance is launched with a single, new network interface with the device index of0. (yes, that's a real condition, don't skip it π)
Returns true on success. π
π SEE ALSO π
VM::EC2
π AUTHOR π
Lincoln Stein <lincoln.stein@gmail.com>.
Copyright (c) 2011 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 β mwah, stan the docs, bye πβ¨π
π¦ where this page comes from
- debian trixie: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- ubuntu resolute: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- ubuntu stonking: libvm-ec2-perl 1.28-5 Β· Artistic-2.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms