Skip to content

Commit

Permalink
Merge pull request #46 from opscode/default_ami
Browse files Browse the repository at this point in the history
Set a sane default EC2 AMI if not provided one
  • Loading branch information
jkeiser committed Aug 21, 2014
2 parents 1483704 + ae73688 commit 69c69a0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/chef_metal_fog/providers/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@ def self.compute_options_for(provider, id, config)
new_config[:driver_options][:aws_account_info] = account_info
id = "#{account_info[:aws_account_id]}:#{result[:driver_options][:compute_options][:region]}"

# Make sure we're using a reasonable default AMI, for now this is Ubuntu 14.04 LTS
result[:machine_options][:bootstrap_options][:image_id] ||=
default_ami_for_region(result[:driver_options][:compute_options][:region])

[result, id]
end

Expand Down Expand Up @@ -343,6 +347,31 @@ def servers_for(machine_specs)
end
result
end

private
def self.default_ami_for_region(region)
Chef::Log.debug("Choosing default AMI for region '#{region}'")

case region
when 'ap-northeast-1'
'ami-c786dcc6'
when 'ap-southeast-1'
'ami-eefca7bc'
when 'ap-southeast-2'
'ami-996706a3'
when 'eu-west-1'
'ami-4ab46b3d'
when 'sa-east-1'
'ami-6770d87a'
when 'us-east-1'
'ami-d2ff23ba'
when 'us-west-1'
'ami-73717d36'
when 'us-west-2'
'ami-f1ce8bc1'
end
end

end
end
end

0 comments on commit 69c69a0

Please sign in to comment.