mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 19:00:14 +00:00
packaging stuff up
This commit is contained in:
22
pkgs/tools/misc/aws-ec2/aws-ec2.sh
Executable file
22
pkgs/tools/misc/aws-ec2/aws-ec2.sh
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Retrieve list of AWS instances
|
||||
# Use enter to jump into their sessions with SSM
|
||||
|
||||
# Specify AWS_PROFILE and AWS_REGION before running this script
|
||||
|
||||
aws ec2 describe-instances \
|
||||
--filters "Name=instance-state-name,Values=running" |
|
||||
jq -r \
|
||||
'.Reservations[]
|
||||
| .Instances[]
|
||||
| .InstanceId + " - " +
|
||||
(.PrivateIpAddress // "n/a") + " - " +
|
||||
(.PublicIpAddress // "n/a") + " - " +
|
||||
(.Tags // [] | from_entries | .Name // "n/a")' |
|
||||
fzf \
|
||||
--height 100% \
|
||||
--layout reverse \
|
||||
--header $'Press Enter to start SSM session\nInstance ID - Private IP - Public IP - Name' \
|
||||
--preview "aws ec2 describe-instances --instance-ids \"\$(echo {} | cut -d' ' -f1)\" | jq -r '.Reservations[].Instances[0]'" \
|
||||
--bind "enter:become(aws ssm start-session --target \$(echo {} | cut -d' ' -f1))"
|
12
pkgs/tools/misc/aws-ec2/package.nix
Normal file
12
pkgs/tools/misc/aws-ec2/package.nix
Normal file
@ -0,0 +1,12 @@
|
||||
{ pkgs, ... }:
|
||||
|
||||
pkgs.writeShellApplication {
|
||||
name = "aws-ec2";
|
||||
runtimeInputs = [
|
||||
pkgs.awscli2
|
||||
pkgs.jq
|
||||
pkgs.fzf
|
||||
pkgs.ssm-session-manager-plugin
|
||||
];
|
||||
text = builtins.readFile ./aws-ec2.sh;
|
||||
}
|
Reference in New Issue
Block a user