provisionator 0.0.18 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9456d0baf6f999eb03d582b97b2d04dc55e16ed2
4
- data.tar.gz: 0700eef879706f2776131259a0326d413b2e99db
3
+ metadata.gz: 82963adf7311538addb67d420d72022bf7167892
4
+ data.tar.gz: d12766be8959ff559f47e09a72dfa2d22531a560
5
5
  SHA512:
6
- metadata.gz: 89005c7ebb14b690483f078beddd284d4d5bf273b49822b566f9c52fbfb5d64679a38aa03870fb7e47e2b15fe2ecc0f367b4285ea848c6baaab91c1a462b1f92
7
- data.tar.gz: f35fcc20a491668089344aa0603aeca78690965a39f25333f65db6faa51b873323f0cc10025f9c73a64d6cfdd03592a73acaa66a9974681abb9b2ff87e3ebcd2
6
+ metadata.gz: 1a4bb193ebc56d38ae0e858e747077c38173c295b12c68aec90d6e041c9d3b236f128237c4073567c959b8278173aff5639e2a0415bcfd8152aa2e7d6b9e7205
7
+ data.tar.gz: 56b7312f688f3e74e4a1498d973dcbce2927be42dec329230d9f53a1a1f431bc4c3488ca712b42c83751e947523f9b86ee4740a687f00fd650d53b12749b834e
@@ -10,17 +10,18 @@ module Provisionator
10
10
  end
11
11
 
12
12
  def initialize options={}
13
- @options = options
13
+ %w{ AWS_REGION AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY}.each do |env_var|
14
+ raise "ENV['#{env_var}'] is required to be set" unless ENV[env_var]
15
+ end
14
16
 
17
+ @options = options
15
18
  @options[:instance_type] ||= ENV['P_INSTANCE_TYPE'] || 'm1.small'
16
19
  @options[:no_release] ||= ENV['P_NO_RELEASE']
17
- @options[:ec2_region] ||= ENV['P_EC2_REGION'] || 'us-east-1'
18
- @options[:ec2_endpoint] ||= ENV['P_EC2_ENDPOINT'] || "ec2.#{@options[:ec2_region]}.amazonaws.com"
19
- @options[:ami_id] ||= ENV['P_AMI_ID']
20
+ @options[:ami_id] ||= ENV['P_AMI_ID'] || ami_id
20
21
  @options[:ebs_volumes] ||= []
21
22
  @options[:key_name] ||= ENV['P_KEY_NAME']
22
23
  @options[:security_groups] ||= ENV['P_SECURITY_GROUPS'].try(:split, ',')
23
- @options[:availability_zones] ||= ENV['P_AVAILABILITY_ZONES'].try(:split, ',') || ec2.regions[@options[:ec2_region]].availability_zones.map(&:name)
24
+ @options[:availability_zones] ||= ENV['P_AVAILABILITY_ZONES'].try(:split, ',') || ec2.availability_zones.map(&:name)
24
25
  @options[:instance_count] ||= ENV['P_INSTANCE_COUNT'].try(:to_i) || 1
25
26
  @options[:load_balancer_name] ||= ENV['P_LOAD_BALANCER_NAME']
26
27
 
@@ -44,10 +45,21 @@ module Provisionator
44
45
 
45
46
  private
46
47
 
48
+ def ami_id
49
+ case ENV['AWS_REGION']
50
+ when 'us-east-1'
51
+ 'ami-bbf799d2'
52
+ when 'ap-southeast-2'
53
+ 'ami-6bcf5c51'
54
+ else
55
+ raise "no ami-id defined for region '#{ENV['AWS_REGION']}'"
56
+ end
57
+ end
58
+
47
59
  def assign_elastic_ip instance
48
60
  return unless @options[:elastic_ip]
49
61
  puts "Assigning #{@options[:elastic_ip]} to #{instance.id}"
50
- ec2_client.associate_address instance_id: instance.id, public_ip: @options[:elastic_ip]
62
+ ec2.client.associate_address instance_id: instance.id, public_ip: @options[:elastic_ip]
51
63
  end
52
64
 
53
65
  def register_with_load_balancer instances
@@ -86,16 +98,12 @@ module Provisionator
86
98
  end
87
99
  end
88
100
 
89
- def ec2_client
90
- @ec2_client ||= AWS::EC2::Client.new(ec2_endpoint: "ec2.#{@options[:ec2_region]}.amazonaws.com")
91
- end
92
-
93
101
  def ec2
94
- @ec2 ||= AWS::EC2.new(ec2_endpoint: "ec2.#{@options[:ec2_region]}.amazonaws.com")
102
+ @ec2 ||= AWS::EC2.new
95
103
  end
96
104
 
97
105
  def elb
98
- @elb ||= AWS::ELB::Client.new(ec2_endpoint: "elasticloadbalancing.#{@options[:ec2_region]}.amazonaws.com")
106
+ @elb ||= AWS::ELB::Client.new
99
107
  end
100
108
 
101
109
  def user_data attributes={}
@@ -1,3 +1,3 @@
1
1
  module Provisionator
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: provisionator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - cmaitchison