Class: EC2::Configuration

Inherits:
Object
  • Object
show all
Includes:
ConfigurationHelper
Defined in:
lib/etude_for_aws/ec2/configuration.rb

Direct Known Subclasses

ConfigurationStub

Constant Summary

Constants included from ConfigurationHelper

ConfigurationHelper::YAML_FILE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigurationHelper

#get_yaml_destination_cidr_block, #get_yaml_ec2_config, #get_yaml_ec2_instances, #get_yaml_internet_gateway, get_yaml_region, #get_yaml_stack_name, #get_yaml_stack_tag_value, #get_yaml_subnet_cidr_block, #get_yaml_subnet_cidr_block_private, #get_yaml_subnet_cidr_block_public, #get_yaml_template_file, #get_yaml_template_path, #get_yaml_vpc_cidr_block, #get_yaml_vpc_route_tables, #get_yaml_vpc_subnets, #get_yaml_vpc_tags, #get_yaml_vpn_info, #get_yaml_zas, load_yaml_file

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/etude_for_aws/ec2/configuration.rb', line 22

def initialize
  ec2_config = get_yaml_ec2_config
  @security_group_name = ec2_config['SECURITY_GROUP_NAME']
  @security_group_description = ec2_config['SECURITY_GROUP_DESCRIPTION']
  @key_pair_name = ec2_config['KEY_PAIR_NAME']
  @key_pair_path = ec2_config['KEY_PAIR_PATH']
  @image_id = ec2_config['IMAGE_ID']
  @instance_type = ec2_config['INSTANCE_TYPE']
  @min_count = ec2_config['MIN_COUNT'].to_i
  @max_count = ec2_config['MAX_COUNT'].to_i

  vpc_tags = get_yaml_vpc_tags
  group_value = vpc_tags['GROUP']['VALUE']
  instances = get_yaml_ec2_instances
  @instance_tags_public = []
  unless instances['PUBLIC'].nil?
    instances['PUBLIC'].each do |v|
      name_value = v['CONFIG']['INSTANCE_TAGS'].first['NAME']['VALUE']
      @instance_tags_public << [{key: 'Name', value: name_value}, {key: 'Group', value: group_value}]
    end
  end
  @instance_tags_private = []
  unless instances['PRIVATE'].nil?
    instances['PRIVATE'].each do |v|
      name_value = v['CONFIG']['INSTANCE_TAGS'].first['NAME']['VALUE']
      @instance_tags_private << [{key: 'Name', value: name_value}, {key: 'Group', value: group_value}]
    end
  end
  @instance_tags = []

  @stub = false
end

Instance Attribute Details

#azObject

Returns the value of attribute az.



5
6
7
# File 'lib/etude_for_aws/ec2/configuration.rb', line 5

def az
  @az
end

#image_idObject (readonly)

Returns the value of attribute image_id.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def image_id
  @image_id
end

#instance_tagsObject

Returns the value of attribute instance_tags.



5
6
7
# File 'lib/etude_for_aws/ec2/configuration.rb', line 5

def instance_tags
  @instance_tags
end

#instance_tags_privateObject (readonly)

Returns the value of attribute instance_tags_private.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def instance_tags_private
  @instance_tags_private
end

#instance_tags_publicObject (readonly)

Returns the value of attribute instance_tags_public.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def instance_tags_public
  @instance_tags_public
end

#instance_typeObject (readonly)

Returns the value of attribute instance_type.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def instance_type
  @instance_type
end

#key_pair_nameObject (readonly)

Returns the value of attribute key_pair_name.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def key_pair_name
  @key_pair_name
end

#key_pair_pathObject (readonly)

Returns the value of attribute key_pair_path.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def key_pair_path
  @key_pair_path
end

#max_countObject (readonly)

Returns the value of attribute max_count.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def max_count
  @max_count
end

#min_countObject (readonly)

Returns the value of attribute min_count.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def min_count
  @min_count
end

#security_group_descriptionObject (readonly)

Returns the value of attribute security_group_description.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def security_group_description
  @security_group_description
end

#security_group_nameObject (readonly)

Returns the value of attribute security_group_name.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def security_group_name
  @security_group_name
end

#stubObject (readonly)

Returns the value of attribute stub.



10
11
12
# File 'lib/etude_for_aws/ec2/configuration.rb', line 10

def stub
  @stub
end

#subnet_idObject

Returns the value of attribute subnet_id.



5
6
7
# File 'lib/etude_for_aws/ec2/configuration.rb', line 5

def subnet_id
  @subnet_id
end

#vpc_idObject

Returns the value of attribute vpc_id.



5
6
7
# File 'lib/etude_for_aws/ec2/configuration.rb', line 5

def vpc_id
  @vpc_id
end

Instance Method Details

#stub?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/etude_for_aws/ec2/configuration.rb', line 55

def stub?
  @stub
end