Giter VIP home page Giter VIP logo

Comments (4)

kyleknap avatar kyleknap commented on August 28, 2024 3

@jason-riddle

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.

jason-riddle avatar jason-riddle commented on August 28, 2024

Sounds good. Thanks!

from awscli-aliases.

ranman avatar ranman commented on August 28, 2024

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.

ranman avatar ranman commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.