fix aws ec2 discovery

This commit is contained in:
Colin Gagnaire 2019-04-08 17:00:55 +02:00
parent a2fdbe2094
commit b5b4dbe20e
1 changed files with 3 additions and 0 deletions

View File

@ -93,6 +93,7 @@ sub discover_ec2 {
my (%options) = @_;
my @disco_data;
my %asgs;
my $instances = $options{custom}->discovery(region => $options{region},
service => 'ec2', command => 'describe-instances');
@ -114,7 +115,9 @@ sub discover_ec2 {
foreach my $tag (@{$instance->{Tags}}) {
if ($tag->{Key} eq "aws:autoscaling:groupName" && defined($tag->{Value})) {
$ec2{asg} = $tag->{Value};
next if (defined($asgs{$tag->{Value}}));
$asg{name} = $tag->{Value};
$asgs{$tag->{Value}} = 1;
}
if ($tag->{Key} eq "Name" && defined($tag->{Value})) {
$ec2{name} = $tag->{Value};