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

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

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:

  • CreateSubnet
  • DeleteSubnet
  • DescribeSubnets

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-created VM::EC2::VPC object.
  • -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 a VM::EC2::AvailabilityZone object. 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. Specify true to indicate that instances launched into the specified subnet should be assigned a public IP address. If set to true, the instance receives a public IP address only if the instance is launched with a single, new network interface with the device index of 0. (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