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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/aws-carb/services/ec2.rb', line 27
def create_instance
instance = nil
ShellSpinner "# creating instance", false do
begin
allowed_ec2_parameters = [
:count,
:iam_instance_profile,
:block_device_mappings,
:virtual_name,
:device_name,
:ebs,
:snapshot_id,
:volume_size,
:delete_on_termination,
:volume_type,
:iops,
:no_device,
:monitoring_enabled,
:availability_zone,
:image_id,
:key_name,
:key_pair,
:security_groups,
:security_group_ids,
:user_data,
:instance_type,
:kernel_id,
:ramdisk_id,
:disable_api_termination,
:instance_initiated_shutdown_behavior,
:subnet,
:private_ip_address,
:dedicated_tenancy,
:ebs_optimized,
:associate_public_ip_address,
]
ec2_config = {}
allowed_ec2_parameters.each do |param|
ec2_config[param] = @config[:ec2][param] if @config[:ec2][param]
end
@instance = @client.instances.create(ec2_config)
rescue => e
puts "# failed to create new ec2 instance:"
die e
end
end
puts
ShellSpinner "# awaiting build completion", false do
sleep 1 until @instance.status != :pending
end
puts
ShellSpinner "# awaiting running state", false do
sleep 1 until @instance.status == :running
end
puts
end
|