14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/itamae/plugin/resource/aws/ebs_volume.rb', line 14
def action_create(options)
ec2 = ::Aws::EC2::Client.new
volumes = ec2.describe_volumes(
{
filters: [
{
name: 'tag:Name',
values: [ attributes.name ],
},
],
}
).volumes
if volumes.empty?
@volume = ec2.create_volume(
size: attributes[:size], availability_zone: attributes.availability_zone,
volume_type: attributes.volume_type,
)
ec2.create_tags(
{
resources: [ @volume.volume_id ],
tags: [
{
key: 'Name',
value: attributes.name,
},
],
}
)
updated!
else
@volume = volumes[0]
end
end
|