Chef Provisioning & AWS Objects not yet supported


#1

We use the Amazon NAT gateways but Chef Provisioning AWS does not yet have support. So, I thought I would roll up my sleeves and use a ruby_block to create them. That went well and I stored the id of the NAT gateway in a databag (similar to the way that Chef Provisioning does). Then, i went to use that string in a aws_route_table resource block and I’m getting an error that I’m not sure how to debug:

RuntimeError
------------
Chef::Resource::AwsInstance[nat-0cea5be928cc9ac09] does not exist!

My NAT gateway is nat-0cea5be928cc9ac09. The resource block in question is:

private_route_table_1 = aws_route_table “private-route-table1-#{node[‘firstfuel’][‘vpc’][‘vpc_name’]}” do
vpc node[‘firstfuel’][‘vpc’][‘vpc_name’]
routes ‘0.0.0.0/0’ => "#{nat_gateway_1[‘reference’][‘id’]}"
aws_tags :chef_type => "aws_route_table"
end

Am I doing something wrong or does the Chef Provisioning AWS gem only support AWS objects that it understands natively?


#2

I was able to get this to work by referencing the interface id of the NAT gateway rather than the NAT gateway ID.


#3

I think if you wanted to fully implement this you would need to define a
Chef::Resource::AwsNatGateway and Chef::Provider::AwsNatGateway class
because it looks like now it’s being detected as an ec2 instance.

That being they’re just ec2 instances under the hood anyway and if it works
then maybe it’s not worth the bother! I’m sure it’ll be added to
provisioning before too long anyway.


#4

Yes, I was trying to avoid implementing any Chef resources for now. My current method seems to be working for now.