Class: AwsEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/ebx/aws_environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ AwsEnvironment

Returns a new instance of AwsEnvironment.



4
5
6
# File 'lib/ebx/aws_environment.rb', line 4

def initialize(settings)
  @settings = settings
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



2
3
4
# File 'lib/ebx/aws_environment.rb', line 2

def settings
  @settings
end

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ebx/aws_environment.rb', line 8

def create
  begin
    if describe[:environments].empty?
      ElasticBeanstalk.instance.client.create_environment(
        application_name: settings['name'],
        version_label: version,
        environment_name: name,
        solution_stack_name: settings['solution_stack'],
        #option_settings: [{
        #  namespace: 'aws:autoscaling:launchconfiguration',
        #  option_name: 'IamInstanceProfile',
        #  option_value: 'ElasticBeanstalkProfile'
        #}]
      )
    end
  rescue Exception
    raise $! # TODO
  end
end

#describeObject



36
37
38
39
40
41
# File 'lib/ebx/aws_environment.rb', line 36

def describe
  binding.pry
  ElasticBeanstalk.instance.client.describe_environments({
    environment_names: [name]
  })
end

#nameObject



32
33
34
# File 'lib/ebx/aws_environment.rb', line 32

def name
  "#{ENV['AWS_ENV']}-#{`git rev-parse --abbrev-ref HEAD`}".strip.gsub(/\s/, '-')[0..23]
end

#versionObject



28
29
30
# File 'lib/ebx/aws_environment.rb', line 28

def version
  `git rev-parse HEAD`
end