Skip to content

Instantly share code, notes, and snippets.

@dontlaugh
Last active June 14, 2019 02:39
Show Gist options
  • Save dontlaugh/3afe54ff5c55af68bbe4d1ca1ef6a76c to your computer and use it in GitHub Desktop.
Save dontlaugh/3afe54ff5c55af68bbe4d1ca1ef6a76c to your computer and use it in GitHub Desktop.
Empty ELBs Deno script
import { dim, red, bold, italic, underline } from "https://deno.land/std/colors/mod.ts";
function printEmptyELBs(elbs: object[]): void {
elbs["LoadBalancerDescriptions"].map((elb) => {
let name = elb["LoadBalancerName"];
let dnsName = elb["DNSName"];
if (elb["Instances"].length < 1) {
console.log(bold(red("Name:")), red(name));
console.log(bold(red("DNS:")), red(dnsName));
console.log(dim(red(" no instances")));
}
});
}
async function main(): Promise<void> {
let v1Output = Deno.run({
args: ["aws", "elb", "describe-load-balancers"],
env: { "AWS_PROFILE": "infra_read_only" },
stdout: "piped",
}).output();
let infraOutput = Deno.run({
args: ["aws", "elb", "describe-load-balancers"],
env: { "AWS_PROFILE": "v1_read_only" },
stdout: "piped",
}).output();
let [v1ELBs, infraELBs] = await Promise.all([v1Output, infraOutput]);
let decodedv1 = JSON.parse(new TextDecoder().decode(v1ELBs));
let decodedInfra = JSON.parse(new TextDecoder().decode(v1ELBs));
let header = (s) => underline(bold(red(s)));
console.log(header("V1"));
printEmptyELBs(decodedv1);
console.log("");
console.log(header("INFRA"));
printEmptyELBs(decodedInfra);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment