VM::EC...y_group(3pm)
π 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)AuthorizeSecurityGroupIngressCreateSecurityGroupDeleteSecurityGroupDescribeSecurityGroupsRevokeSecurityGroupEgress(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:
π οΈ 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
- 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