Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add associate_public_ip option #56

Closed
wants to merge 1 commit into from
Closed
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: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ For specific default values, please consult [amis.json][amis_json].

## <a name="config"></a> Configuration

### <a name="config-associate-public-ap"></a> associate\_public\_ip

Instances created within a [Virtual Private Cloud (VPC)][vpc_docs] will not
automatically have a public IP address allocated. Set this option to `true` to
allocate a public IP and associate it with the launched instance.

Note that this setting has no effect on instances launched into EC2-Classic
(i.e., instances not launched into a VPC).

The default is `false`.

### <a name="config-az"></a> availability\_zone

**Required** The AWS [availability zone][region_docs] to use.
Expand Down Expand Up @@ -283,3 +294,4 @@ Apache 2.0 (see [LICENSE][license])
[kitchenci]: http://kitchen.ci/
[region_docs]: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
[subnet_docs]: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html
[vpc_docs]: http://docs.aws.amazon.com/AmazonVPC/latest/GettingStartedGuide/ExerciseOverview.html
17 changes: 10 additions & 7 deletions lib/kitchen/driver/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ module Driver
# @author Fletcher Nichol <fnichol@nichol.ca>
class Ec2 < Kitchen::Driver::SSHBase

default_config :region, 'us-east-1'
default_config :availability_zone, 'us-east-1b'
default_config :flavor_id, 'm1.small'
default_config :ebs_optimized, false
default_config :security_group_ids, ['default']
default_config :tags, { 'created-by' => 'test-kitchen' }
default_config :iam_profile_name, nil
default_config :region, 'us-east-1'
default_config :availability_zone, 'us-east-1b'
default_config :flavor_id, 'm1.small'
default_config :ebs_optimized, false
default_config :security_group_ids, ['default']
default_config :tags, { 'created-by' => 'test-kitchen' }
default_config :iam_profile_name, nil
default_config :associate_public_ip, false
default_config :aws_access_key_id do |driver|
ENV['AWS_ACCESS_KEY'] || ENV['AWS_ACCESS_KEY_ID']
end
Expand Down Expand Up @@ -118,6 +119,7 @@ def create_server
debug_server_config

connection.servers.create(
:associate_public_ip => config[:associate_public_ip],
:availability_zone => config[:availability_zone],
:security_group_ids => config[:security_group_ids],
:tags => config[:tags],
Expand All @@ -132,6 +134,7 @@ def create_server

def debug_server_config
debug("ec2:region '#{config[:region]}'")
debug("ec2:associate_public_ip '#{config[:associate_public_ip]}'")
debug("ec2:availability_zone '#{config[:availability_zone]}'")
debug("ec2:flavor_id '#{config[:flavor_id]}'")
debug("ec2:ebs_optimized '#{config[:ebs_optimized]}'")
Expand Down