class AwsEc2::Base
Constants
- BUILD_ROOT
- SCRIPTS_INFO_PATH
constants really only used by script classes
Public Class Methods
new(options={})
click to toggle source
# File lib/aws_ec2/base.rb, line 7 def initialize(options={}) @options = options.clone @name = randomize(@options[:name]) AwsEc2.validate_in_project! end
Public Instance Methods
derandomize(name)
click to toggle source
Strip the random string at end of the ec2 instance name
# File lib/aws_ec2/base.rb, line 33 def derandomize(name) if @options[:randomize] name.sub(/-(\w{3})$/,'') # strip the random part at the end else name end end
randomize(name)
click to toggle source
Appends a short random string at the end of the ec2 instance name. Later we will strip this same random string from the name. Very makes it convenient. We can just type:
aws-ec2 create server --randomize
instead of:
aws-ec2 create server-123 --profile server
# File lib/aws_ec2/base.rb, line 23 def randomize(name) if @options[:randomize] random = (0...3).map { (65 + rand(26)).chr }.join.downcase # Ex: jhx [name, random].join('-') else name end end