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

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

πŸ’– VM::EC2::REST::security_group πŸ’–

okay so bestie, welcome to the manual page for VM::EC2::REST::security_group, which lives under User Contributed Perl Documentation and is giving firewall-rule royalty. It's part of the VM::EC2 family, and honestly? She's a whole vibe. Sit down, grab a lil drink, we're going through the entire thing together β€” no skips, no skimming. πŸ’…


🌸 NAME 🌸

VM::EC2::REST::security_group β€” query and manipulate security groups ✨

πŸŽ€ SYNOPSIS πŸŽ€

use VM::EC2 ':standard';

that's it. that's the synopsis. she's lowkey minimal and we respect her for it. πŸ¦‹


🫢 METHODS 🫢

The methods in this section let you query and manipulate security groups β€” which is just the fancy way of saying firewall rules, iykyk. If you want the functionality that's available through the objects themselves, go peek at VM::EC2::SecurityGroup. That's where the object-level magic lives. πŸ’–

Implemented:

  • AuthorizeSecurityGroupEgress (EC2-VPC only)
  • AuthorizeSecurityGroupIngress
  • CreateSecurityGroup
  • DeleteSecurityGroup
  • DescribeSecurityGroups
  • RevokeSecurityGroupEgress (EC2-VPC only)
  • RevokeSecurityGroupIngress

Unimplemented:

  • (none)

not a single one left unimplemented, she ate and left no crumbs πŸ‘‘


πŸ” describe_security_groups

@sg = $ec2->describe_security_groups(@group_ids)
@sg = $ec2->describe_security_groups(%args)
@sg = $ec2->describe_security_groups(\%filters)

So what this one does: it searches for security groups (firewall rules, bestie, keep up πŸ’€) that match whatever filters you hand it, and it returns a whole series of VM::EC2::SecurityGroup objects. Iconic.

When you go with the named-argument form, these optional arguments are yours to play with:

  • -group_name β€” a single group name, or an arrayref holding a list of names
  • -name β€” the shorter version of -group_name
  • -group_id β€” a single group id (like 'sg-12345') or an arrayref holding a list of ids
  • -filter β€” filter on tags and other attributes

And here's a lil quality-of-life thing: you can omit the -filter argument name entirely if there aren't any other arguments you want to pass. cute, right?

The full list of security group filters lives over here, go look:

http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSecurityGroups.html


πŸ› οΈ create_security_group

$group = $ec2->create_security_group(-group_name=>$name,
    -group_description=>$description, -vpc_id     => $vpc_id )

This one creates a security group. The arguments are:

  • -group_name β€” name of the security group (required)
  • -group_description β€” description of the security group (required)
  • -vpc_id β€” virtual private cloud security group ID (required for VPC security groups)

And for convenience (because we love convenience πŸ’…), you can use -name and -description as aliases for -group_name and -group_description respectively.

If it works out, the method hands you back an object of type VM::EC2::SecurityGroup. πŸŽ€


πŸ—‘οΈ delete_security_group

$boolean = $ec2->delete_security_group($group_id)
$boolean = $ec2->delete_security_group(-group_id   => $group_id, -group_name
    => $name);

Bye bye security group, we hardly knew ye. ✨ The arguments are:

  • -group_name β€” name of the security group
  • -group_id β€” ID of the security group

You need either -group_name or -group_id β€” one of them, bestie, not neither. And in the single-argument form, the method deletes the security group given by its id.

If it goes through, the method returns true. 🫢


πŸ”„ update_security_group

$boolean = $ec2->update_security_group($security_group)

This one adds one or more incoming firewall rules to a security group. The rules you're adding are stored in a VM::EC2::SecurityGroup, which you get either from describe_security_groups() or from create_security_group(). This method is basically a mashup β€” it combines the actions AuthorizeSecurityGroupIngress, AuthorizeSecurityGroupEgress, RevokeSecurityGroupIngress, and RevokeSecurityGroupEgress. four-for-one, we love a bundle. πŸ”₯

For the full details, go read VM::EC2::SecurityGroup. But here's a lil summary for you:

$sg = $ec2->create_security_group(-name=>'MyGroup',-description=>'Example group');

# TCP on port 80 for the indicated address ranges
$sg->authorize_incoming(-protocol  => 'tcp',
                        -port      => 80,
                        -source_ip => ['192.168.2.0/24','192.168.2.1/24']);

# TCP on ports 22 and 23 from anyone
$sg->authorize_incoming(-protocol  => 'tcp',
                        -port      => '22..23',
                        -source_ip => '0.0.0.0/0');

# ICMP on echo (ping) port from anyone
$sg->authorize_incoming(-protocol  => 'icmp',
                        -port      => -1,
                        -source_ip => '0.0.0.0/0');

# TCP to port 25 (mail) from instances belonging to
# the "Mail relay" group belonging to user 12345678.
$sg->authorize_incoming(-protocol  => 'tcp',
                        -port      => 25,
                        -group     => '12345678/Mail relay');

$result = $ec2->update_security_group($sg);

or, honestly, more simply:

$result = $sg->update();

look at her. one line. main character energy. πŸ‘‘


🌈 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.


okay that's the whole page, bestie, you made it to the end and I'm so proud of you πŸ₯Ήβœ¨

and one last lil sign-off for the record: this is perl v5.38.2, dated 2024-08-10, and the page is VM::EC2::REST::security_group (3pm). now go authorize something responsibly. πŸ’–πŸŒΈπŸ¦‹

πŸ“¦ where this page comes from