chef-provisioning-aws
chef-provisioning-aws copied to clipboard
adding default attr values for aws_ebs_volume introduced runtime error
volume = aws_ebs_volume 'ha-ebs' do
availability_zone "#{node['qa-chef-server-cluster']['aws']['availability_zone']}" # => 'b'
size 1
device '/dev/xvdf'
aws_tags node['qa-chef-server-cluster']['aws']['machine_options']['aws_tags']
end
# Breaks on the attachment resource
aws_ebs_volume 'ha-ebs' do
machine 'bootstrap-backend'
end
It's comparing the default availability_zone 'a' to the 'b' in the previous resource.
RuntimeError
------------
aws_ebs_volume[ha-ebs] (vol-1eb0e10c).availability_zone is us-west-2a, but actual volume has availability_zone_name set to us-west-2b. Cannot be modified!
Need to update resource to recall the availability_zone value when checking the immutable options.
applies to :size as well
There's a conflict here on the premise of allowing chef-provisioning to set sensible defaults, and the notion of failing the run when immutable attributes are changed via the resources. The easy fix here would be to remove the default attribute values, and making the on-create attributes required (like device).
Another option would be to flip the idea of allowing chef provisioning to run but log a warning instead of raising the exception. I don't particularly like this idea, but its an option.
Yeah, this is a good example of why it can be tricky to set defaults
for attributes in Chef. I didn't think about this back then.
The way we fixed this was to not have any defaults on immutable attributes, and instead defaulting them in the provider during the action_create
method