Skip to content
This repository has been archived by the owner on Jun 28, 2019. It is now read-only.

fix multi region issue #83

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/cap-ec2/ec2-handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,14 @@ def instance_has_tag?(instance, key, value)

def instance_status_ok?(instance)
@ec2.any? do |_, ec2|
ec2.describe_instance_status(
instance_ids: [instance.instance_id],
filters: [{ name: 'instance-status.status', values: %w(ok) }]
).instance_statuses.length == 1
begin
ec2.describe_instance_status(
instance_ids: [instance.instance_id],
filters: [{ name: 'instance-status.status', values: %w(ok) }]
).instance_statuses.length == 1
rescue Aws::EC2::Errors::InvalidInstanceIDNotFound
false
end
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/cap-ec2/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def load_config
end

config_location = File.expand_path(fetch(:ec2_config), Dir.pwd) if fetch(:ec2_config)
if config_location && File.exists?(config_location)
config = YAML.load(ERB.new(File.read(fetch(:ec2_config))))
if config_location && File.exist?(config_location)
config = YAML.load(ERB.new(File.read(fetch(:ec2_config))).result)
if config
set :ec2_project_tag, config['project_tag'] if config['project_tag']
set :ec2_roles_tag, config['roles_tag'] if config['roles_tag']
Expand Down