fix(aws/health): events mode - limit issue with paws (#2732)

This commit is contained in:
qgarnier 2021-04-23 09:37:07 +02:00 committed by GitHub
parent 0df621c812
commit cf2b2c162e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 17 deletions

View File

@ -619,25 +619,24 @@ sub health_describe_affected_entities {
eval {
my $lwp_caller = new Paws::Net::LWPCaller();
my $health = Paws->service('Health', caller => $lwp_caller, region => $self->{option_results}->{region});
my $health_options = { Filter => {} };
if (defined($options{filter_event_arns})) {
$health_options->{Filter}->{EventArns} = $options{filter_event_arns};
}
while ((my $entities = $health->DescribeAffectedEntities(%$health_options))) {
foreach (@{$entities->{Entities}}) {
push @$entities_results, {
entityArn => $_->{EntityArn},
eventArn => $_->{EventArn},
entityValue => $_->{EntityValue},
awsAccountId => $_->{AwsAccountId},
lastUpdatedTime => $_->{LastUpdatedTime},
statusCode => $_->{StatusCode}
};
while (my @events = splice(@{$options{filter_event_arns}}, 0, 10)) {
my $health_options = { Filter => { EventArns => \@events } };
while ((my $entities = $health->DescribeAffectedEntities(%$health_options))) {
foreach (@{$entities->{Entities}}) {
push @$entities_results, {
entityArn => $_->{EntityArn},
eventArn => $_->{EventArn},
entityValue => $_->{EntityValue},
awsAccountId => $_->{AwsAccountId},
lastUpdatedTime => $_->{LastUpdatedTime},
statusCode => $_->{StatusCode}
};
}
last if (!defined($entities->{NextToken}));
$health_options->{NextToken} = $entities->{NextToken};
}
last if (!defined($entities->{NextToken}));
$health_options->{NextToken} = $entities->{NextToken};
}
};
if ($@) {