lib/capistrano/asg/rolling/ami.rb in capistrano-asg-rolling-0.1.0 vs lib/capistrano/asg/rolling/ami.rb in capistrano-asg-rolling-0.2.0
- old
+ new
@@ -23,16 +23,16 @@
name: name,
description: description
}
if tags
- options[:tag_specifications] = tags.flat_map do |key, value|
- [
- { resource_type: 'image', tags: [{ key: key, value: value }] },
- { resource_type: 'snapshot', tags: [{ key: key, value: value }] }
- ]
- end
+ tag_specifications = tags.map { |key, value| { key: key, value: value } }
+
+ options[:tag_specifications] = [
+ { resource_type: 'image', tags: tag_specifications },
+ { resource_type: 'snapshot', tags: tag_specifications }
+ ]
end
response = aws_ec2_client.create_image(options)
begin
@@ -61,9 +61,27 @@
def snapshots
@snapshots ||= aws_ec2_image.block_device_mappings.map do |mapping|
Snapshot.new(mapping.ebs.snapshot_id)
end
+ end
+
+ def tags
+ @tags ||= aws_ec2_image.tags.map { |tag| [tag.key, tag.value] }.to_h
+ end
+
+ def tag?(key)
+ tags.key?(key)
+ end
+
+ def ==(other)
+ id == other.id
+ end
+
+ alias eql? ==
+
+ def hash
+ id.hash
end
private
def aws_ec2_image