Module: Enscalator::Plugins::AmazonLinux
- Defined in:
- lib/enscalator/plugins/amazon_linux.rb
Overview
Amazon Linux appliance
Constant Summary collapse
- STORAGE =
Supported storage types in AWS
[:ebs, :'instance-store']
- EBS_VOLUME_TYPES =
Supported EBS volume types
[:standard, :gp2]
- ARCH =
Supported Debian image architectures
[:x86_64, :i386]
Class Method Summary collapse
-
.get_ami(region:, release: '2015.09.1', storage: :ebs, arch: :x86_64, ebs_type: :gp2, filters: {}) ⇒ String
First ami-id found for the query.
Instance Method Summary collapse
-
#amazon_linux_init(region: self.region, release: '2015.09.1', storage: :ebs, arch: :x86_64, ebs_type: :gp2, filters: {}) ⇒ Object
Create AMI id parameter for an Amazon linux instance.
Class Method Details
.get_ami(region:, release: '2015.09.1', storage: :ebs, arch: :x86_64, ebs_type: :gp2, filters: {}) ⇒ String
Returns first ami-id found for the query.
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 54 55 56 |
# File 'lib/enscalator/plugins/amazon_linux.rb', line 24 def get_ami(region:, release: '2015.09.1', storage: :ebs, arch: :x86_64, ebs_type: :gp2, filters: {}) fail ArgumentError, "storage can only be one of #{STORAGE}" unless STORAGE.include? storage fail ArgumentError, "arch can only be one of #{ARCH}" unless ARCH.include? arch fail ArgumentError, "ebs_type can only be one of #{EBS_VOLUME_TYPES}" unless EBS_VOLUME_TYPES.include? ebs_type client = Aws::EC2::Client.new(region: region) resp = client.describe_images( owners: ['amazon'], filters: [ { name: 'name', values: %W(amzn-ami-hvm-#{release}* amzn-ami-pv-#{release}*) }, { name: 'root-device-type', values: [storage.to_s] }, { name: 'architecture', values: [arch.to_s] } ] + filters_map_to_array(filters) ) err_msg = format('Could not find any Linux Amazon Ami that fits the criteria: %s, %s, %s, %s, %s, %s', region, release, storage, arch, ebs_type, filters) fail StandardError, err_msg unless resp.images images = resp.images.sort_by(&:creation_date).reverse images = images.select { |i| i.block_device_mappings.first.ebs.volume_type == ebs_type.to_s } if storage == :ebs images.first.image_id end |
Instance Method Details
#amazon_linux_init(region: self.region, release: '2015.09.1', storage: :ebs, arch: :x86_64, ebs_type: :gp2, filters: {}) ⇒ Object
Create AMI id parameter for an Amazon linux instance
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/enscalator/plugins/amazon_linux.rb', line 78 def amazon_linux_init(region: self.region, release: '2015.09.1', storage: :ebs, arch: :x86_64, ebs_type: :gp2, filters: {}) parameter_ami 'AmazonLinux', AmazonLinux.get_ami(region: region, release: release, storage: storage, arch: arch, ebs_type: ebs_type, filters: filters) end |