Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Visualize container dependencies from ECS task definition JSON.
#!/usr/bin/env perl
use 5.12.1;
use warnings;
use JSON::PP;
my $file = shift;
open my $in, "<", $file or die $!;
my $taskdef = JSON::PP::decode_json(do { local $/ = undef; <$in> });
my $g = $file;
$g =~ s/[^\w]/_/g;
say "digraph $g {";
for my $c (@{$taskdef->{taskDefinition}->{containerDefinitions}}) {
my $name = $c->{name};
for my $dep (@{$c->{dependsOn}}) {
printf qq{ %s -> %s [label = "%s"];\n},
$name, $dep->{containerName}, $dep->{condition};
}
}
say "}";
#!/usr/bin/env ruby
require 'json'
file = ARGV[0]
taskdef = open(file) do |f|
JSON.load(f)
end
gname = file.gsub(/[^\w]/, '_')
puts "digraph #{gname} {"
taskdef['taskDefinition']['containerDefinitions'].each do |c|
name = c['name']
c['dependsOn']&.each do |dep|
puts " #{name} -> #{dep['containerName']} [label = \"#{dep['condition']}\"];"
end
end
puts '}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.