lib/meroku/aws.rb in meroku-2.0.23 vs lib/meroku/aws.rb in meroku-2.0.24

- old
+ new

@@ -3,31 +3,37 @@ module Meroku # Mostly wrappers around aws library functions module Aws include Meroku::Shared - def make_instance - @instance_id = Meroku::Shared.ec2_client.run_instances( + def default_instance_params + { 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 + def make_instance + @instance_id = + Meroku::Shared \ + .ec2_client \ + .run_instances(default_instance_params) \ + .instances.fetch(0).instance_id + puts 'waiting' + Meroku::Shared.ec2_client.wait_until( + :instance_running, + instance_ids: [@instance_id] + ) + end + 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 + Meroku::Shared.ec2_client.associate_address( + allocation_id: allocation_id, instance_id: instance_id + ) end # Private S3 Bucket # The only security here is not no one knows the bucket name, # which is a uuid