Child pages
  • Deploying on Amazon EC2

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

AWS is a great platform for scripted control of your EC2 instances. See https://aws.amazon.com/tools/ for information on command-line tools and SDKs for other languages, such as java, python, C++, and all the others needed for buzzword-compliance. Here is an example CLI script.

     #!/bin/bash

     # Note that these scripts rely on having 'StrictHostKeyChecking accept-new' in the ~/.ssh/config file.
     #
     # For jq, a sort of sed for json data, see https://stedolan.github.io/jq/

     echo ""

     id=`aws ec2 describe-instances | jq --raw-output '.Reservations[0].Instances[0].InstanceId'`

     status=`aws ec2 describe-instances --instance-ids $id | jq --raw-output '.Reservations[0].Instances[0].State.Name'`

     if [ $status = "running" ]; then

         ip=`aws ec2 describe-instances --instance-ids $id | jq --raw-output '.Reservations[0].Instances[0].PublicIpAddress'`

         echo "instance-id: $id status: $status 'ubuntu@$ip'"
     else

         echo "instance-id: $id status: $status"
     fi

     echo ""

     exit 0

Amazon Linux 2

Instructions for Amazon Linux 2 are TBD.

...