Project

ec2i3

0.0
No commit activity in last 3 years
No release in over 3 years
EC2 in 3 steps: step 1. register the AWS account details in the XML registry, step 2. launch the EC2 instance, step 3. Publish the status of the instance using SimplePubSub.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.1, >= 0.1.12
>= 0.1.0, ~> 0.1
>= 0.2.0, ~> 0.2
~> 0.5, >= 0.5.5
>= 0.6.0, ~> 0.6
 Project Readme

Introducing the EC2i3 gem

require 'ec2i3'

reg = XMLRegistry.new '/home/james/da2/registry/registry.xml'
e = EC2i3.new reg, address: '192.168.4.140'
e.start 'windows', duration: 2

The above example fetches the Amazon Web Services (AWS) credentials from the XML registry, launches the Windows EC2 instance, and then publishes the public IP address to the SimplePubSub broker. After 2 minutes the Windows EC2 instance is stopped, and a further SimplePubSub message is published to notify subscribers of topic EC2i3 that the instance is stopping.

How to create a ec2i3.reg file for importing into the XML registry

Before running this script you need to have a valid AWS access_key + AWS private_key, and have generated a ?Dynarex-password lookup file http://www.jamesrobertson.eu/snippets/2012/may/04/introducing-the-dynarex-password-gem.html?.

require 'leetpassword'
require 'dynarex-password'
require 'encrypt'

access_key = 'your_aws_accessid'
private_key = 'your_aws_privatekey'
lookup_file = '/home/james/password-010915.xml'

dp = DynarexPassword.new
passphrase = LeetPassword.generate(8)
encrypted_passphrase = dp.lookup(passphrase, lookup_file)

encrypted_private_key = Encrypt.dump(private_key, passphrase).\
                                                   each_byte.to_a.join(' ')
private_key = Encrypt.load(encrypted_private_key.\
                             split(' ').map(&:to_i).pack('C*'), passphrase)

s = "
hkey_apps/ec2i3
access_key_id: #{access_key}
private_key: #{encrypted_private_key}
lookup_file: #{lookup_file}
passphrase: #{encrypted_passphrase}
"

File.write 'ec2i3.reg', s

Resources

ec2i3 gem ec2 aws sps