Allocating an Elastic IP with aws_eip_address

Hi,

Given a machine named “foo”, I am trying to create a new Elastic IP address using the following recipe:

name = “foo"
aws_eip_address “#{name}-eip” do
machine name
action :create
end

I’m getting the following exception and stacktrace:

IPAddr::AddressFamilyError: address family must be specified
/opt/chefdk/embedded/lib/ruby/2.1.0/ipaddr.rb:475:in initialize' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/resource/aws_eip_address.rb:28:innew’
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/resource/aws_eip_address.rb:28:in block in <class:AwsEipAddress>' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/property.rb:555:ininstance_exec’
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/property.rb:555:in exec_in_resource' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/property.rb:393:incoerce’
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/property.rb:301:in get' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/property.rb:247:incall’
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/property.rb:451:in public_ip' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb:113:inpublic_send’
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb:113:in should_have_managed_entry?' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb:43:inget_id_from_managed_entry’
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb:84:in get_driver_and_id' /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-provisioning-aws-1.4.1/lib/chef/provisioning/aws_driver/aws_resource_with_entry.rb:59:into_s’

For some reason, coerce on the resource is called with nil as the value, so the code calls IPAddr.new(nil), presumably because I didn’t specify a public_ip attribute. If I specify that, it works, but obviously I don’t want to have to do that - I want the resource to create the elastic IP itself, using the create action.

How is this supposed to work? Is it a bug?

Jos

@Jos_Backus I suspect that you opened the discussion with an issue report over here: https://github.com/chef/chef-provisioning-aws/issues/366
I think that’s the best way to handle this issue.
-M

Yep, that’s me. I banged my head against the wall for a while, then I decided to just debug it myself.