Module: Meroku::Aws
Overview
Mostly wrappers around aws library functions
Class Method Summary collapse
Instance Method Summary collapse
-
#allocation_id ⇒ Object
Our elastic ip allocation.
- #associate_address ⇒ Object
-
#bucket ⇒ Object
Private S3 Bucket The only security here is not no one knows the bucket name, which is a uuid.
- #ip_address ⇒ Object
- #make_instance ⇒ Object
- #tag ⇒ Object
Methods included from Shared
Class Method Details
.running_filter(tag) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/meroku/aws.rb', line 70 def self.running_filter(tag) [ { name: 'tag:Name', values: [tag] }, { name: 'instance-state-name', values: %w[running pending] } ] end |
.terminate_all(tag: nil) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/meroku/aws.rb', line 39 def self.terminate_all(tag: nil) Meroku::Shared.ec2_client.describe_instances( filters: running_filter(tag) ).reservations.map do |r| id = r.instances.first.instance_id puts "Will terminate #{id}" Meroku::Shared.ec2_client.terminate_instances(instance_ids: [id]) end end |
Instance Method Details
#allocation_id ⇒ Object
Our elastic ip allocation
50 51 52 |
# File 'lib/meroku/aws.rb', line 50 def allocation_id 'eipalloc-139f7823' end |
#associate_address ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/meroku/aws.rb', line 19 def associate_address retries ||= 0 sleep 10 begin puts Meroku::Shared.ec2_client.associate_address( allocation_id: allocation_id, instance_id: instance_id ).class sleep 20 rescue ::Aws::EC2::Errors::InvalidInstanceID (retries += 1) < 10 ? retry : raise end end |
#bucket ⇒ Object
Private S3 Bucket The only security here is not no one knows the bucket name, which is a uuid
35 36 37 |
# File 'lib/meroku/aws.rb', line 35 def bucket "http://s3.amazonaws.com/#{Meroku::Shared.secrets.meroku_secret}/" end |
#ip_address ⇒ Object
54 55 56 |
# File 'lib/meroku/aws.rb', line 54 def ip_address '34.239.241.218' end |
#make_instance ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/meroku/aws.rb', line 8 def make_instance @instance_id = Meroku::Shared.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.instance_id end |
#tag ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/meroku/aws.rb', line 58 def tag { resource_type: 'instance', tags: [ { key: 'Name', value: 'node' } ] } end |