Class: ImageBuilder::Builders::AWS::Base

Inherits:
Base
  • Object
show all
Defined in:
lib/image_builder/builders/aws_base.rb

Overview

Generic class doc comment

Direct Known Subclasses

Chroot, EBS, Instance

Constant Summary

Constants included from ImageBuilder

VERSION

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



47
48
49
50
51
# File 'lib/image_builder/builders/aws_base.rb', line 47

def initialize
  @access_key = ENV['AWS_ACCESS_KEY_ID'] || ENV['AWS_ACCESS_KEY']
  @secret_key = ENV['AWS_SECRET_ACCESS_KEY'] || ENV['AWS_SECRET_KEY']
  @region = 'us-east-1'
end

Instance Attribute Details

#access_keyObject

Returns the value of attribute access_key.



8
9
10
# File 'lib/image_builder/builders/aws_base.rb', line 8

def access_key
  @access_key
end

#ami_block_device_mappingsObject

  • opt -



16
17
18
# File 'lib/image_builder/builders/aws_base.rb', line 16

def ami_block_device_mappings
  @ami_block_device_mappings
end

#ami_descriptionObject

Returns the value of attribute ami_description.



17
18
19
# File 'lib/image_builder/builders/aws_base.rb', line 17

def ami_description
  @ami_description
end

#ami_groupsObject

Returns the value of attribute ami_groups.



18
19
20
# File 'lib/image_builder/builders/aws_base.rb', line 18

def ami_groups
  @ami_groups
end

#ami_nameObject

Returns the value of attribute ami_name.



9
10
11
# File 'lib/image_builder/builders/aws_base.rb', line 9

def ami_name
  @ami_name
end

#ami_product_codesObject

Returns the value of attribute ami_product_codes.



19
20
21
# File 'lib/image_builder/builders/aws_base.rb', line 19

def ami_product_codes
  @ami_product_codes
end

#ami_regionsObject

Returns the value of attribute ami_regions.



20
21
22
# File 'lib/image_builder/builders/aws_base.rb', line 20

def ami_regions
  @ami_regions
end

#ami_usersObject

Returns the value of attribute ami_users.



21
22
23
# File 'lib/image_builder/builders/aws_base.rb', line 21

def ami_users
  @ami_users
end

#ami_virtualization_typeObject

Returns the value of attribute ami_virtualization_type.



22
23
24
# File 'lib/image_builder/builders/aws_base.rb', line 22

def ami_virtualization_type
  @ami_virtualization_type
end

#associate_public_ip_addressObject

Returns the value of attribute associate_public_ip_address.



23
24
25
# File 'lib/image_builder/builders/aws_base.rb', line 23

def associate_public_ip_address
  @associate_public_ip_address
end

#availability_zoneObject

Returns the value of attribute availability_zone.



24
25
26
# File 'lib/image_builder/builders/aws_base.rb', line 24

def availability_zone
  @availability_zone
end

#enhanced_networkingObject

Returns the value of attribute enhanced_networking.



25
26
27
# File 'lib/image_builder/builders/aws_base.rb', line 25

def enhanced_networking
  @enhanced_networking
end

#iam_instance_profileObject

Returns the value of attribute iam_instance_profile.



26
27
28
# File 'lib/image_builder/builders/aws_base.rb', line 26

def iam_instance_profile
  @iam_instance_profile
end

#instance_typeObject

Returns the value of attribute instance_type.



10
11
12
# File 'lib/image_builder/builders/aws_base.rb', line 10

def instance_type
  @instance_type
end

#launch_block_device_mappingsObject

Returns the value of attribute launch_block_device_mappings.



27
28
29
# File 'lib/image_builder/builders/aws_base.rb', line 27

def launch_block_device_mappings
  @launch_block_device_mappings
end

#regionObject

Returns the value of attribute region.



11
12
13
# File 'lib/image_builder/builders/aws_base.rb', line 11

def region
  @region
end

#run_tagsObject

Returns the value of attribute run_tags.



28
29
30
# File 'lib/image_builder/builders/aws_base.rb', line 28

def run_tags
  @run_tags
end

#secret_keyObject

Returns the value of attribute secret_key.



12
13
14
# File 'lib/image_builder/builders/aws_base.rb', line 12

def secret_key
  @secret_key
end

#security_group_idObject

Returns the value of attribute security_group_id.



29
30
31
# File 'lib/image_builder/builders/aws_base.rb', line 29

def security_group_id
  @security_group_id
end

#security_group_idsObject

Returns the value of attribute security_group_ids.



30
31
32
# File 'lib/image_builder/builders/aws_base.rb', line 30

def security_group_ids
  @security_group_ids
end

#source_amiObject

Returns the value of attribute source_ami.



13
14
15
# File 'lib/image_builder/builders/aws_base.rb', line 13

def source_ami
  @source_ami
end

#spot_priceObject

Returns the value of attribute spot_price.



31
32
33
# File 'lib/image_builder/builders/aws_base.rb', line 31

def spot_price
  @spot_price
end

#spot_price_auto_productObject

Returns the value of attribute spot_price_auto_product.



32
33
34
# File 'lib/image_builder/builders/aws_base.rb', line 32

def spot_price_auto_product
  @spot_price_auto_product
end

#ssh_portObject

Returns the value of attribute ssh_port.



33
34
35
# File 'lib/image_builder/builders/aws_base.rb', line 33

def ssh_port
  @ssh_port
end

#ssh_private_ipObject

Returns the value of attribute ssh_private_ip.



35
36
37
# File 'lib/image_builder/builders/aws_base.rb', line 35

def ssh_private_ip
  @ssh_private_ip
end

#ssh_private_key_fileObject

Returns the value of attribute ssh_private_key_file.



34
35
36
# File 'lib/image_builder/builders/aws_base.rb', line 34

def ssh_private_key_file
  @ssh_private_key_file
end

#ssh_timeoutObject

Returns the value of attribute ssh_timeout.



36
37
38
# File 'lib/image_builder/builders/aws_base.rb', line 36

def ssh_timeout
  @ssh_timeout
end

#ssh_usernameObject

Returns the value of attribute ssh_username.



14
15
16
# File 'lib/image_builder/builders/aws_base.rb', line 14

def ssh_username
  @ssh_username
end

#subnet_idObject

Returns the value of attribute subnet_id.



37
38
39
# File 'lib/image_builder/builders/aws_base.rb', line 37

def subnet_id
  @subnet_id
end

#tagsObject

Returns the value of attribute tags.



38
39
40
# File 'lib/image_builder/builders/aws_base.rb', line 38

def tags
  @tags
end

#temporary_key_pair_nameObject

Returns the value of attribute temporary_key_pair_name.



39
40
41
# File 'lib/image_builder/builders/aws_base.rb', line 39

def temporary_key_pair_name
  @temporary_key_pair_name
end

#tokenObject

Returns the value of attribute token.



40
41
42
# File 'lib/image_builder/builders/aws_base.rb', line 40

def token
  @token
end

#typeObject (readonly)

Returns the value of attribute type.



45
46
47
# File 'lib/image_builder/builders/aws_base.rb', line 45

def type
  @type
end

#user_dataObject

Returns the value of attribute user_data.



41
42
43
# File 'lib/image_builder/builders/aws_base.rb', line 41

def user_data
  @user_data
end

#user_data_fileObject

Returns the value of attribute user_data_file.



42
43
44
# File 'lib/image_builder/builders/aws_base.rb', line 42

def user_data_file
  @user_data_file
end

#vpc_idObject

Returns the value of attribute vpc_id.



43
44
45
# File 'lib/image_builder/builders/aws_base.rb', line 43

def vpc_id
  @vpc_id
end

Class Method Details

.default_block_device_mappingsObject



53
54
55
56
57
58
59
60
# File 'lib/image_builder/builders/aws_base.rb', line 53

def self.default_block_device_mappings
  [
    { device_name: '/dev/sdf', virtual_name: 'ephemeral0' },
    { device_name: '/dev/sdg', virtual_name: 'ephemeral1' },
    { device_name: '/dev/sdh', virtual_name: 'ephemeral2' },
    { device_name: '/dev/sdi', virtual_name: 'ephemeral3' }
  ]
end

.default_launch_block_device_mappingsObject



62
63
64
65
66
67
68
# File 'lib/image_builder/builders/aws_base.rb', line 62

def self.default_launch_block_device_mappings
  [
    { device_name: '/dev/sdb', no_device: true },
    { device_name: '/dev/sdc', no_device: true },
    { device_name: '/dev/sdd', no_device: true }
  ]
end

Instance Method Details

#packer_hashObject



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
# File 'lib/image_builder/builders/aws_base.rb', line 70

def packer_hash
  hash = {}

  req_attrs = [
    :type, :name, :access_key, :ami_name, :instance_type,
    :region, :secret_key, :source_ami, :ssh_username
  ]

  opt_attrs = [
    :ami_description, :ami_groups, :ami_product_codes, :ami_regions, :ami_regions, :ami_users,
    :ami_virtualization_type, :associate_public_ip_address, :availability_zone, :enhanced_networking,
    :iam_instance_profile, :run_tags, :security_group_id, :security_group_ids, :spot_price,
    :spot_price_auto_product, :ssh_port, :ssh_private_key_file, :ssh_private_ip, :ssh_timeout,
    :subnet_id, :tags, :temporary_key_pair_name, :token, :user_data, :user_data_file, :vpc_id,
    :launch_block_device_mappings, :ami_block_device_mappings
  ]

  # Required attrs
  req_attrs.each do |a|
    attr_to_hash(hash, a, true)
  end

  opt_attrs.each do |a|
    attr_to_hash(hash, a)
  end

  hash
end