Module: Meroku::Aws::Ec2
- Included in:
- CLI, Infrastructure, Infrastructure::Server, Node
- Defined in:
- lib/meroku/aws/ec2.rb
Overview
Logic related to the ec2 instances we use as servers
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.associate_address(eipalloc, id) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/meroku/aws/ec2.rb', line 49 def self.associate_address(eipalloc, id) retries ||= 0 ec2_client.associate_address(allocation_id: eipalloc, instance_id: id) rescue ::Aws::EC2::Errors::InvalidInstanceID sleep 1 puts 'retrying associate_address()' retry if (retries += 1) < 15 end |
.ec2_client ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/meroku/aws/ec2.rb', line 39 def self.ec2_client ::Aws::EC2::Client.new( region: 'us-east-1', credentials: ::Aws::Credentials.new( ENV['AWS_ACCESS_KEY'], ENV['AWS_SECRET'] ) ) end |
Instance Method Details
#ec2_client ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/meroku/aws/ec2.rb', line 29 def ec2_client ::Aws::EC2::Client.new( region: 'us-east-1', credentials: ::Aws::Credentials.new( ENV['AWS_ACCESS_KEY'], ENV['AWS_SECRET'] ) ) end |
#make_instance ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/meroku/aws/ec2.rb', line 18 def make_instance ec2_client.run_instances( image_id: 'ami-841f46ff', min_count: 1, max_count: 1, key_name: 'meroku.id_rsa', instance_type: 't2.micro', tag_specifications: [tag] ).instances.first end |
#tag ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/meroku/aws/ec2.rb', line 6 def tag { resource_type: 'instance', tags: [ { key: 'Name', value: 'node' } ] } end |