Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Scripting creating AWS based servers

coldclimate
January 27, 2014

Scripting creating AWS based servers

in the most Taco Bell way I know

coldclimate

January 27, 2014
Tweet

More Decks by coldclimate

Other Decks in Technology

Transcript

  1. Man => Document Removing the bus factor “The man we

    can’t fire” @coldclimate CANDDi.com
  2. Build Twice Raw OS Base Instance Script “Base Box” Make

    AMI “Base Box” “Instance Box” Script Base AMI @coldclimate CANDDi.com
  3. ec2-run-instances --region 'eu-west-1' -g TEMP -k TEMP -f install.sh -t

    t1.micro ami-ce7b6fba @coldclimate CANDDi.com
  4. apt-get -y install zip unzip xmlstarlet sysstat iftop ntp sysvbanner

    build- essential python-setuptools nginx nodejs @coldclimate CANDDi.com
  5. wget https://github.com/nicolasff/phpredis/archive/2.2.4.zip -P /tmp/ mkdir -p /opt/code unzip /tmp/2.2.4.zip -d

    /opt/code/ cd /opt/code/phpredis-2.2.4 phpize ./configure make make install @coldclimate CANDDi.com
  6. ec2-run-instances --region 'eu-west-1' -g sg-bb18b66c -k LIVE-PEM-KEY -p Instance_Profile -f

    install.sh -t m1.small --availability-zone eu-west-1a --disable-api-termination ami-XXXXXX @coldclimate CANDDi.com
  7. Roles http://docs.aws.amazon.com/cli/latest/reference/iam/create-role.html Instance Profiles http://docs.aws.amazon.com/cli/latest/reference/iam/create-instance-profile.html Adding a Role to an

    Instance Profile http://docs.aws.amazon.com/cli/latest/reference/iam/add-role-to-instance-profile.html @coldclimate CANDDi.com
  8. Download from S3 Setup directories Setup config Install code Start

    it up Register it @coldclimate CANDDi.com
  9. Download from S3 python <<PY import boto import sys from

    boto.s3.key import Key def get_wonka(bucket_name, file_name, destination_file): conn = boto.connect_s3() bucket = conn.get_bucket(bucket_name) k = Key(bucket) k.name = file_name destination = "/tmp/%s" % (destination_file) k.get_contents_to_filename(destination) get_wonka("BUCKET","SOURCEFILE","DESTINATION") PY @coldclimate CANDDi.com
  10. Setup config Copy it from the download into place Restart

    the service @coldclimate CANDDi.com