Comments (4)
I want to add these to the repository. I just need to clean them up a bit before adding them. For the authorize-my-ip
and connect-ssh
, these are more or less how I defined them:
authorize-my-ip =
!f() {
my_cidr=<INSERT_CIDR_BLOCK_HERE>
aws ec2 authorize-security-group-ingress --group-id "${1}" \
--port 22 --protocol tcp --cidr "$my_cidr"
}; f
connect-ssh =
!f() {
instance_output=$(aws ec2 describe-instances \
--instance-ids "${1}" \
--query Reservations[0].Instances[0])
ssh_key_file=$(jp -u KeyName <<< "$instance_output")".pem"
public_ip=$(jp -u PublicIpAddress <<< "$instance_output")
if ! [ -f "$ssh_key_file" ];
then
echo "Error: Could not locate SSH key: "$ssh_key_file" in current" \
"working direcory"
exit 1
fi
if [ "$public_ip" == "null" ];
then
echo "EC2 Instance: "${1}" does not have a public IP address." \
"Unable to connect with SSH."
exit 1
fi
ssh -i "$ssh_key_file" ec2-user@"$public_ip"
}; f
For the first one, I want to convert to a subcommand alias possibly and for the second alias I want to remove the dependency on jp
and use a builtin UNIX command line tool instead in order to make it easier to use out of the box.
As to the auto-configure
alias, it is shelling out to a python script that I have located on disk. I want to expose the script and the alias in the alias repository as well, but I need to clean it up a bit before I do so.
from awscli-aliases.
Sounds good. Thanks!
from awscli-aliases.
could you do (to replace jp usage):
instance_output=($(aws ec2 describe-instances \
--instance-ids "${1}" \
--query 'Reservations[0].Instances[0].[KeyName,PublicIpAddress] | join(`" "`, @)' | tr -d '"'
))
ssh_key_file=$instance_output[1]".pem"
public_ip=$instance_output[2]
from awscli-aliases.
hey @kyleknap does that combo of join
and tr
work for you? works for me locally but didn't test widely.
from awscli-aliases.
Related Issues (11)
- Support multiple alias files HOT 1
- Can't use --profile HOT 17
- Functions ignore command line options HOT 1
- What other stanzas are available besides `toplevel`? HOT 4
- Add aliases to tab completion HOT 3
- Cannot use options for echo command
- Anyone at the helm?
- 'f' is not recognized as an internal or external command
- bash autocomplete HOT 6
- QuickSight
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from awscli-aliases.