function deleteNetworkInterface()

in automated-actions/AWS_ELASTICLOADBALANCING_ENI_LIMIT_REACHED/LambdaFunction.js [51:74]


function deleteNetworkInterface (networkInterfaceId, dryrun) {
    console.log ('Running code to delete ENI %s with Dry Run set to %s', networkInterfaceId, dryrun);
    var deleteNetworkInterfaceParams = {
        NetworkInterfaceId: networkInterfaceId,
        DryRun: dryrun
    };
    ec2.deleteNetworkInterface(deleteNetworkInterfaceParams, function(err, data) {
        if (err) 
        {
            switch (err.code)
            {
                case 'DryRunOperation':
                    console.log('Dry run attempt complete for %s after %s retries', networkInterfaceId, this.retryCount);
                    break;
                case 'RequestLimitExceeded':
                    console.log('Request limit exceeded while processing %s after %s retries', networkInterfaceId, this.retryCount);
                    break;
                default:
                    console.log(networkInterfaceId, err, err.stack);    
            }
        }
        else console.log('ENI %s deleted after %s retries', networkInterfaceId, this.retryCount);  // successful response
    });
}