App-FargateStack
view release on metacpan or search on metacpan
lib/App/EC2.pm view on Meta::CPAN
########################################################################
my ( $self, $security_group_name, $description ) = @_;
croak "usage: create_security_group(name, description)\n"
if !$security_group_name || !$description;
return $self->command(
'create-security-group' => [
'--group-name' => $security_group_name,
'--description' => $description,
'--vpc-id' => $self->get_vpc_id,
'--query' => 'GroupId',
'--output' => 'text',
]
);
}
########################################################################
sub revoke_security_group_ingress {
########################################################################
my ( $self, %args ) = @_;
my ( $group_id, $port, $protocol, $source_group ) = @args{qw(group_id port protocol source_group)};
$protocol //= 'tcp';
$port //= '80';
return $self->command(
'revoke-security-group-ingress' => [
'--group-id' => $group_id,
'--port' => $port,
'--protocol' => $protocol,
'--source-group' => $source_group,
]
);
}
########################################################################
sub authorize_security_group_ingress {
########################################################################
my ( $self, %args ) = @_;
my ( $group_id, $port, $protocol, $source_group, $cidr ) = @args{qw(group_id port protocol source_group cidr)};
$protocol //= 'tcp';
$port //= '80';
return $self->command(
'authorize-security-group-ingress' => [
'--group-id' => $group_id,
'--port' => $port,
'--protocol' => $protocol,
$cidr ? ( '--cidr' => $cidr ) : (),
$source_group ? ( '--source-group' => $source_group ) : (),
]
);
}
########################################################################
sub validate_subnets {
########################################################################
my ( $self, $subnets ) = @_;
# flatten private, public subnets
my @all_subnets = map { @{ $subnets->{$_} // [] } } keys %{$subnets};
my @valid_subnets = map { $_->{SubnetId} } @{ $self->describe_subnets()->{Subnets} };
foreach my $s (@all_subnets) {
croak sprintf "ERROR: The subnet [%s] does not exist in vpc: [%s]\nvalid subnets: \n\t%s\n", $s,
$self->get_vpc_id, join "\n\t", @valid_subnets
if none { $_ eq $s } @valid_subnets;
}
return;
}
########################################################################
sub delete_security_group {
########################################################################
my ( $self, $security_group_id ) = @_;
return $self->command( 'delete-security-group' => [ '--group-id' => $security_group_id ] );
}
########################################################################
sub describe_network_interfaces {
########################################################################
my ( $self, $eni_list, $query ) = @_;
return $self->command(
'describe-network-interfaces' => [
'--network-interface-ids' => ( ref $eni_list ? @{$eni_list} : $eni_list ),
$query ? ( '--query' => $query ) : ()
]
);
}
1;
( run in 0.886 second using v1.01-cache-2.11-cpan-39bf76dae61 )