function getMatchingInstances()

in automated-actions/AWS_EC2_INSTANCE_STORE_DRIVE_PERFORMANCE_DEGRADED/LambdaFunction.js [10:29]


function getMatchingInstances(affectedEntities){
    //initialize an empty array
    var instances = [];
    // loop through entities
    for ( var i=0; i < affectedEntities.length; i+=1 )
    {
        var instanceId = affectedEntities[i].entityValue;
        // check that the instance has tags
        if (typeof (affectedEntities[i].tags) != 'undefined') {
            // check that tags match
            if (affectedEntities[i].tags[[tagKey]] == tagValue){
                // add instanceid to the array
                instances.push(instanceId);
            }
            else console.log ('The following instance does not match the configured tag: ', instanceId);
        }
        else console.log ('The following instance does not match the configured tag: ', instanceId);
    }
    return instances
}