Open chrisroberts opened 8 years ago
FYI rake task for doing the diff with aws-sdk
task :changeset, [:stack, :file] do |_t, args|
client = ... make a cloudformation client ...
options = {
change_set_name: "TestChangeset#{rand(9999999)}", # make sure not to reuse a old one
stack_name: args.fetch(:stack)
}
file = args.fetch(:file)
file = File.expand_path(file).sub("#{Dir.pwd}/", '')
raise "File not found #{file}" unless File.exist?(file)
folder, file = file.split('/', 2)
template = `cd #{folder} && sfn print -f #{file}`
raise "FAIL #{template}" unless $?.success?
begin
client.create_change_set(
options.merge(template_body: template)
)
# change takes a few seconds to be generated
r = nil
loop do
r = client.describe_change_set(options)
break unless ["CREATE_IN_PROGRESS", "CREATE_PENDING"].include? r.status
sleep 0.5
end
if r.status == "FAILED"
abort r.status_reason
else
r.changes.each do |change|
rs = change.resource_change
puts "#{rs.resource_type} #{rs.logical_resource_id} #{rs.action} Scope: #{rs.scope} Replace: #{rs.replacement}"
end
end
ensure
client.delete_change_set(options)
end
end
I'm less than impressed with the functionality of the changesets feature as a viable standalone implementation for the aws planner mainly due to lack of functionality specifically in relation to nesting. Instead I'm going to look at augmenting the existing planner with the changesets functionality to cover things the existing planner can't easily implement (like conditional update effects based on things like backing type of amis).
yep, atm we use both ... sfn to get the detailed diff and changeset as a sanity check to make sure we don't do a restart by accident.
CFN has finally opened native planner-ish interface. Implement support via optional callback.