-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstory.bash
39 lines (34 loc) · 1.58 KB
/
story.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
id=$(config id)
aws ec2 describe-instances --instance-id $id \
--query 'Reservations[*].Instances[*].{
ID:InstanceId,St:State,Time:LaunchTime,IP:PublicIpAddress,IP2:PrivateIpAddress,Tags:Tags,Devices:BlockDeviceMappings,Subnet:SubnetId,AZ:Placement.AvailabilityZone }' | perl -n -MJSON -e '
$json.=$_;
END {
#print $json;
my $ii = decode_json($json);
for $i (map {$_->[0]} @$ii){
write();
}
}
format STDOUT =
----------------------------------------------------------------------------------------------------------------
ID Public IP Private IP Time State
----------------------------------------------------------------------------------------------------------------
@<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<< @>>>>>>>>>>>>>>>>>> @<<<<<<<<<<<<<<<<< ~
$i->{ID}, $i->{IP}||'Null', $i->{IP2}||'Null', $i->{Time}, join "/", ($i->{St}{Code}, $i->{St}{Name})
----------------------------------------------------------------------------------------------------------------
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"Subnet: ".($i->{Subnet})
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
"AvailabilityZone: $i->{AZ}"
---------------------------------------------------------------/
Tags:
@*
join "\n", map { ($_->{Key})." : ".($_->{Value}) } @{$i->{Tags}}
---------------------------------------------------------------/
EBS:
@*
join "\n", map { ($_->{DeviceName})." => ".( $_->{Ebs}->{VolumeId} ) } grep {$_->{Ebs}} @{$i->{Devices}}
---------------------------------------------------------------/
.
'