feat(cloud-aws) add s3 bucket discovery

This commit is contained in:
Sims24 2019-09-24 08:44:19 +02:00 committed by Colin Gagnaire
parent 25fa5b96e1
commit 657f177647
1 changed files with 21 additions and 1 deletions

View File

@ -44,7 +44,8 @@ sub new {
VPN => $self->can('discover_vpn'),
KINESIS => $self->can('discover_kinesis_stream'),
DYNAMODB => $self->can('discover_dynamodb_table'),
APIGATEWAY => $self->can('discover_api')
APIGATEWAY => $self->can('discover_api'),
S3 => $self->can('discover_s3_bucket')
};
return $self;
@ -214,6 +215,25 @@ sub discover_kinesis_stream {
return @disco_data;
}
sub discover_s3_bucket {
my (%options) = @_;
my @disco_data;
my $buckets = $options{custom}->discovery(region => $options{region},
service => 's3api', command => 'list-buckets');
foreach my $bucket (@{$buckets->{Buckets}}) {
my %bucket;
$bucket{type} = "s3_bucket";
$bucket{name} = $bucket->{Name};
$bucket{creation_date} = $bucket->{CreationDate};
push @disco_data, \%bucket;
}
return @disco_data;
}
sub discover_dynamodb_table {
my (%options) = @_;