Module: AWSCarb

Defined in:
lib/aws-carb.rb,
lib/aws-carb/config.rb,
lib/aws-carb/version.rb,
lib/aws-carb/user_data.rb,
lib/aws-carb/services/ec2.rb,
lib/aws-carb/services/route53.rb,
lib/aws-carb/cli_argument_parser.rb

Defined Under Namespace

Modules: CliArgumentParser, Services Classes: Config, UserData

Constant Summary collapse

VERSION =
"0.0.7"

Class Method Summary collapse

Class Method Details



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/aws-carb.rb', line 42

def self.banner
  banner = <<-HEREDOC.strip_heredoc

     ::::::::      :::     :::::::::  :::::::::  
    :+:    :+:   :+: :+:   :+:    :+: :+:    :+: 
    +:+         +:+   +:+  +:+    +:+ +:+    +:+ 
    +#+        +#++:++#++: +#++:++#:  +#++:++#+  
    +#+        +#+     +#+ +#+    +#+ +#+    +#+ 
    #+#    #+# #+#     #+# #+#    #+# #+#    #+# 
     ########  ###     ### ###    ### #########  

        - cloudinit and route53 bootstrap -

  HEREDOC

  indent = ' ' * 6

  puts banner.each_line.map { |line| indent + line }
end

.runObject



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/aws-carb.rb', line 62

def self.run

  #
  # configuration
  #

  # parse cli args
  cli_arguments = CliArgumentParser.parse

  # display banner on successful cli argument parsing..
  banner

  # create a configuration based on our various data sources..
  @config = Config.instance
  @config.create(cli_arguments)
  @config.display if $GLOBAL_VERBOSE

  # load erb template and parse the template with user_data_template_variables
  # then merge user_data template with raw user_data (if provided) -
  # end up single user_data ready to pass into ec2 instance..
  @user_data = UserData.instance
  @user_data.create(@config)
  @user_data.display if @config[:user_data_template][:file] and ($GLOBAL_VERBOSE or @config[:show_parsed_template])

  #
  # aws interaction
  # 
  if @config[:route53].andand[:new_dns_records]
    @route53 = Services::Route53.instance
    @route53.client(@config)
    @route53.check_hostname_and_domain_availability
  end

  ## initialize ec2 object with credentials
  @ec2 = Services::Ec2.instance
  @ec2.client(@config)
  @ec2.create_instance

  if @config[:route53].andand[:new_dns_records]
    @route53.create_records(@ec2)
  end

  #
  # summary
  # 

  show_instance_details
end

.show_instance_detailsObject



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/aws-carb.rb', line 111

def self.show_instance_details
  puts <<-HEREDOC.strip_heredoc
    # instance details:
    id:               #{@ec2.instance.id}
    public ip:        #{@ec2.instance.public_ip_address}
    public aws fqdn:  #{@ec2.instance.public_dns_name}
    private ip:       #{@ec2.instance.private_ip_address}
    private aws fqdn: #{@ec2.instance.private_dns_name}
  HEREDOC

  unless @config[:route53][:new_dns_records].nil?
    puts <<-HEREDOC.strip_heredoc
      public fqdn:      #{@config[:route53][:new_dns_records][:public][:alias]}
      private fqdn:     #{@config[:route53][:new_dns_records][:private][:alias]}
    HEREDOC
  end

  puts <<-HEREDOC.strip_heredoc
    
    # connect: 
    ssh #{@ec2.instance.dns_name} -l ubuntu
  HEREDOC
end