Class: MovableInk::AWS
- Inherits:
-
Object
- Object
- MovableInk::AWS
- Defined in:
- lib/movable_ink/aws.rb,
lib/movable_ink/aws/s3.rb,
lib/movable_ink/aws/ec2.rb,
lib/movable_ink/aws/sns.rb,
lib/movable_ink/aws/ssm.rb,
lib/movable_ink/version.rb,
lib/movable_ink/aws/athena.rb,
lib/movable_ink/aws/errors.rb,
lib/movable_ink/aws/route53.rb,
lib/movable_ink/aws/autoscaling.rb
Defined Under Namespace
Modules: Athena, Autoscaling, EC2, Errors, Route53, S3, SNS, SSM
Constant Summary collapse
- VERSION =
'0.1.9'
Class Method Summary collapse
Instance Method Summary collapse
- #availability_zone ⇒ Object
- #datacenter(region: my_region) ⇒ Object
-
#initialize(environment: nil) ⇒ AWS
constructor
A new instance of AWS.
- #my_region ⇒ Object
- #regions ⇒ Object
- #run_with_backoff(quiet: false) ⇒ Object
Methods included from S3
Methods included from Athena
Methods included from SSM
#extract_parameters, #get_role_secrets, #get_secret, #ssm
Methods included from Route53
#list_all_r53_resource_record_sets, #resource_record_sets, #route53
Methods included from Autoscaling
#autoscaling, #complete_lifecycle_action, #delete_role_tag, #mark_me_as_healthy, #mark_me_as_unhealthy, #record_lifecycle_action_heartbeat
Methods included from SNS
#notify_and_sleep, #notify_nsq_can_not_be_drained, #notify_slack, #sns, #sns_slack_topic_arn
Methods included from EC2
#all_instances, #assign_ip_address, #available_elastic_ips, #ec2, #elastic_ips, #instance_id, #instance_ip_addresses_by_role, #instance_ip_addresses_by_role_ordered, #instances, #load_all_instances, #load_mi_env, #load_thopter_instance, #me, #mi_env, #private_ip_addresses, #redis_by_role, #statsd_host, #thopter, #thopter_instance, #unassigned_elastic_ips
Constructor Details
#initialize(environment: nil) ⇒ AWS
Returns a new instance of AWS.
33 34 35 |
# File 'lib/movable_ink/aws.rb', line 33 def initialize(environment: nil) @mi_env = environment end |
Class Method Details
.regions ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/movable_ink/aws.rb', line 23 def regions { 'iad' => 'us-east-1', 'rld' => 'us-west-2', 'dub' => 'eu-west-1', 'ord' => 'us-east-2' } end |
Instance Method Details
#availability_zone ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/movable_ink/aws.rb', line 65 def availability_zone @availability_zone ||= begin az = `ec2metadata --availability-zone 2>/dev/null`.chomp raise(MovableInk::AWS::Errors::EC2Required) if az.empty? az end end |
#datacenter(region: my_region) ⇒ Object
77 78 79 |
# File 'lib/movable_ink/aws.rb', line 77 def datacenter(region: my_region) regions.key(region) end |
#my_region ⇒ Object
73 74 75 |
# File 'lib/movable_ink/aws.rb', line 73 def my_region @my_region ||= availability_zone.chop end |
#regions ⇒ Object
61 62 63 |
# File 'lib/movable_ink/aws.rb', line 61 def regions self.class.regions end |
#run_with_backoff(quiet: false) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/movable_ink/aws.rb', line 37 def run_with_backoff(quiet: false) 9.times do |num| begin return yield rescue Aws::EC2::Errors::RequestLimitExceeded, Aws::SNS::Errors::ThrottledException, Aws::AutoScaling::Errors::ThrottledException, Aws::S3::Errors::SlowDown, Aws::Route53::Errors::ThrottlingException, Aws::Route53::Errors::ServiceError, Aws::SSM::Errors::TooManyUpdates, Aws::Athena::Errors::ThrottlingException, MovableInk::AWS::Errors::NoEnvironmentTagError sleep_time = (num+1)**2 + rand(10) if quiet (num >=8) ? notify_and_sleep(sleep_time, $!.class) : sleep(sleep_time) else notify_and_sleep(sleep_time, $!.class) end end end raise MovableInk::AWS::Errors::FailedWithBackoff end |