$ stack-
stack-arn stack-exports stack-tag-apply
stack-asg-instances stack-failure stack-tag-delete
stack-asgs stack-instances stack-tags
stack-cancel-update stack-outputs stack-tags-text
stack-create stack-parameters stack-tail
stack-delete stack-recreate stack-template
stack-diff stack-resources stack-update
stack-elbs stack-status stack-validate
stack-events stack-tag $ sort <(
user-playlists alice | playlist-tracks
user-playlists bob | playlist-tracks
) | uniq --repeated $ bma type instances
instances is a function
instances ()
{
local instance_ids=$(__bma_read_inputs);
local filters=$(__bma_read_filters $@);
aws ec2 describe-instances $([[ -n ${instance_ids} ]] && echo --instance-ids ${instance_ids}) --query "
Reservations[].Instances[][
InstanceId,
InstanceType,
State.Name,
[Tags[?Key=='Name'].Value][0][0],
LaunchTime,
Placement.AvailabilityZone,
VpcId
]" --output text | grep -E -- "$filters" | LC_ALL=C sort -b -k 6 | column -s' ' -t
} $ instances
i-03dfa28fc8235df7b t3.nano running prometheus 2019-12-31T14:10:45.000Z ap-southeast-2a vpc-9def06f8
i-0fd7a4c81051f2718 t3.nano running huginn 2019-12-31T14:10:44.000Z ap-southeast-2a vpc-9def06f8
i-0abcd6e9c302f35bb t3.nano running rails-demo 2019-12-31T14:10:47.000Z ap-southeast-2b vpc-9def06f8
$ instances | grep rails-demo | instance-asg | asg-capacity
rails-demo-AutoScalingGroup-14SBR6O3W1FBL 0 1 2
$ instances | grep rails-demo | instance-asg | asg-
asg-capacity asg-launch-configuration asg-processes_suspended asg-stack
asg-desired-size-set asg-max-size-set asg-resume asg-suspend
asg-instances asg-min-size-set asg-scaling-activities
$ instances | grep rails-demo | instance-asg | asg-desired-size-set 2
$ instances | grep rails-demo | instance-asg | asg-capacity
rails-demo-AutoScalingGroup-14SBR6O3W1FBL 0 2 2 instances() {
local instance_ids=$(__bma_read_inputs)
local filters=$(__bma_read_filters $@)
aws ec2 describe-instances \
$([[ -n ${instance_ids} ]] && echo --instance-ids ${instance_ids}) \
--query "
Reservations[].Instances[][
InstanceId,
InstanceType,
State.Name,
[Tags[?Key=='Name'].Value][0][0],
LaunchTime,
Placement.AvailabilityZone,
VpcId
]" \
--output text |
grep -E -- "$filters" |
LC_ALL=C sort -b -k 6 |
column -s$'\t' -t
}
The AWCLI, as well as SDKs all support grabbing Regions and account credentials from environment variables.
For Regions, I work tend to use the following aliases:
I normally work in a single Region and swap when required by typing the 2 character alias.
To run a script or command (doesn't have to be Bash-my-AWS) across all Regions I use region-each:
For AWS accounts, I type the name of the account and I'm in. For accounts using IDP (ldap/AD backed corporate logins) I generate aliases so I have tab completion and simple naming.
In accounts that are only setup to use AWS keys, I use aliases that export credentials kept in GPG encrypted files. Last time I looked, AWS docs suggested keeping these long lives credentials in plaintext files readable by your account. That's asking for trouble IMO, especially if they're kept in a known location that a compromised node library could exfiltrate them from.
AWSCLI v2 beta includes support for SSO so it's probably a good time to look at how BMA could include support for auth.