| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CCfn { |
|
2
|
14
|
|
|
14
|
|
672903
|
use Moose; |
|
|
14
|
|
|
|
|
3743259
|
|
|
|
14
|
|
|
|
|
110
|
|
|
3
|
|
|
|
|
|
|
extends 'Cfn'; |
|
4
|
|
|
|
|
|
|
|
|
5
|
14
|
|
|
14
|
|
109536
|
use Cfn; |
|
|
14
|
|
|
|
|
54
|
|
|
|
14
|
|
|
|
|
641
|
|
|
6
|
14
|
|
|
14
|
|
6962
|
use CCfnX::DynamicValue; |
|
|
14
|
|
|
|
|
43
|
|
|
|
14
|
|
|
|
|
8400
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has stash => ( |
|
9
|
|
|
|
|
|
|
is => 'ro', |
|
10
|
|
|
|
|
|
|
isa => 'HashRef', |
|
11
|
|
|
|
|
|
|
default => sub { {} }, |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Holds the mappings from logical output name, to the output name that will be sent and retrieved from cloudformation |
|
15
|
|
|
|
|
|
|
# This is done to support characters in the output names that cloudformation doesn't |
|
16
|
|
|
|
|
|
|
has output_mappings => ( |
|
17
|
|
|
|
|
|
|
is => 'rw', |
|
18
|
|
|
|
|
|
|
isa => 'HashRef[Str]', |
|
19
|
|
|
|
|
|
|
default => sub { {} }, |
|
20
|
|
|
|
|
|
|
); |
|
21
|
|
|
|
|
|
|
has debug => (is => 'ro', default => sub { return $ENV{ CLOUDDEPLOY_DEBUG } ? 1 : 0 }); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Small helper to map a Moose class (parameters have a type) to a CloudFormation type |
|
24
|
|
|
|
|
|
|
sub _moose_to_cfn_class { |
|
25
|
|
|
|
|
|
|
return { |
|
26
|
|
|
|
|
|
|
Str => 'String', |
|
27
|
|
|
|
|
|
|
Int => 'Number', |
|
28
|
|
|
|
|
|
|
Num => 'Number', |
|
29
|
0
|
|
0
|
0
|
|
0
|
}->{ $_[0] } || 'String'; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# When the object is instanced, we want any of the attributes declared in the class to be created |
|
33
|
|
|
|
|
|
|
# That means that attributes with Resource, Output, Condition or Output roles are "attached" to the object |
|
34
|
|
|
|
|
|
|
# This is done to make the newly created object represent all that the user has declared "in the class" when |
|
35
|
|
|
|
|
|
|
# they call ->new |
|
36
|
|
|
|
|
|
|
# All these attributes are normally created with CCfnX::Shortcuts, but can really be created by hand (not recommended) |
|
37
|
|
|
|
|
|
|
sub BUILD { |
|
38
|
32
|
|
|
32
|
0
|
69731
|
my $self = shift; |
|
39
|
32
|
|
|
|
|
267
|
my $class_meta = $self->meta; |
|
40
|
32
|
|
|
|
|
767
|
my @attrs = $class_meta->get_all_attributes; |
|
41
|
32
|
|
|
|
|
2619
|
foreach my $att (@attrs) { |
|
42
|
531
|
|
|
|
|
365582
|
my $name = $att->name; |
|
43
|
531
|
100
|
|
|
|
1485
|
if ($att->does('CCfnX::Meta::Attribute::Trait::Resource')) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
44
|
73
|
|
|
|
|
18477
|
$self->addResource($name, $self->$name); |
|
45
|
|
|
|
|
|
|
} elsif ($att->does('CCfnX::Meta::Attribute::Trait::Output')){ |
|
46
|
4
|
|
|
|
|
2992
|
$self->addOutput($name, $self->$name); |
|
47
|
|
|
|
|
|
|
} elsif ($att->does('CCfnX::Meta::Attribute::Trait::Condition')){ |
|
48
|
0
|
|
|
|
|
0
|
$self->addCondition($name, $self->$name); |
|
49
|
|
|
|
|
|
|
} elsif ($att->does('CCfnX::Meta::Attribute::Trait::Metadata')){ |
|
50
|
4
|
|
|
|
|
6173
|
$self->Metadata->{ $name } = Cfn::Value->new(Value => $self->$name); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
32
|
|
|
|
|
20029
|
my $params_meta = $self->params->meta; |
|
55
|
32
|
|
|
|
|
1035
|
@attrs = $params_meta->get_all_attributes; |
|
56
|
32
|
|
|
|
|
2026
|
foreach my $param (@attrs) { |
|
57
|
271
|
50
|
|
|
|
54511
|
if ($param->does('CCfnX::Meta::Attribute::Trait::StackParameter')) { |
|
58
|
0
|
|
|
|
|
0
|
my $type = $param->type_constraint->name; |
|
59
|
0
|
|
|
|
|
0
|
$self->addParameter($param->name, _moose_to_cfn_class($type)); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_stackversion_from_metadata { |
|
66
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
67
|
0
|
|
|
|
|
0
|
$self->Metadata->{ StackVersion }; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
before as_hashref => sub { |
|
71
|
|
|
|
|
|
|
my $self = shift; |
|
72
|
|
|
|
|
|
|
# This triggers any actions that the class |
|
73
|
|
|
|
|
|
|
# wants to do while building the cloudformation |
|
74
|
|
|
|
|
|
|
$self->build(); |
|
75
|
|
|
|
|
|
|
}; |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
around addOutput => sub { |
|
78
|
|
|
|
|
|
|
my ($orig, $self, $name, $output) = @_; |
|
79
|
|
|
|
|
|
|
my $new_name = $name; |
|
80
|
|
|
|
|
|
|
$new_name =~ s/\W//g; |
|
81
|
|
|
|
|
|
|
if (defined $self->Outputs->{ $new_name }) { |
|
82
|
|
|
|
|
|
|
die "The output name clashed with an existing output name. Be aware that outputs are stripped of all non-alphanumeric chars before being declared"; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
if ($new_name ne $name) { |
|
85
|
|
|
|
|
|
|
$self->output_mappings->{ $new_name } = $name; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
$self->$orig($new_name, $output); |
|
88
|
|
|
|
|
|
|
}; |
|
89
|
|
|
|
|
|
|
|
|
90
|
14
|
|
|
14
|
|
7647
|
use Data::Graph::Util qw//; |
|
|
14
|
|
|
|
|
9716
|
|
|
|
14
|
|
|
|
|
1661
|
|
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub _creation_order { |
|
93
|
2
|
|
|
2
|
|
6817
|
my ($self) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
2
|
|
|
|
|
6
|
my $graph = {}; |
|
96
|
2
|
|
|
|
|
77
|
foreach my $resource ($self->ResourceList) { |
|
97
|
20
|
|
|
|
|
606
|
$graph->{ $resource } = $self->Resource($resource)->dependencies; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
64
|
my @result = Data::Graph::Util::toposort($graph, [ sort $self->ResourceList ]); |
|
101
|
|
|
|
|
|
|
|
|
102
|
2
|
|
|
|
|
507
|
return reverse @result; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
7
|
0
|
|
sub build {} |
|
106
|
|
|
|
|
|
|
|
|
107
|
14
|
|
|
14
|
|
166
|
use Module::Runtime qw//; |
|
|
14
|
|
|
|
|
37
|
|
|
|
14
|
|
|
|
|
2000
|
|
|
108
|
|
|
|
|
|
|
sub get_deployer { |
|
109
|
0
|
|
|
0
|
0
|
|
my ($self, $params, @roles) = @_; |
|
110
|
0
|
|
|
|
|
|
Module::Runtime::require_module($_) for ('CCfnX::Deployment', @roles); |
|
111
|
0
|
|
|
|
|
|
my $dep = CCfnX::Deployment->new_with_roles({ %$params, origin => $self }, @roles); |
|
112
|
0
|
|
|
|
|
|
return $dep; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::RefValue { |
|
117
|
14
|
|
|
14
|
|
114
|
use Moose::Role; |
|
|
14
|
|
|
|
|
179
|
|
|
|
14
|
|
|
|
|
157
|
|
|
118
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('RefValue'); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::StackParameter { |
|
122
|
14
|
|
|
14
|
|
78842
|
use Moose::Role; |
|
|
14
|
|
|
|
|
34
|
|
|
|
14
|
|
|
|
|
62
|
|
|
123
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('StackParameter'); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::Resource { |
|
127
|
14
|
|
|
14
|
|
72893
|
use Moose::Role; |
|
|
14
|
|
|
|
|
41
|
|
|
|
14
|
|
|
|
|
75
|
|
|
128
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('Resource'); |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::Metadata { |
|
132
|
14
|
|
|
14
|
|
72747
|
use Moose::Role; |
|
|
14
|
|
|
|
|
30
|
|
|
|
14
|
|
|
|
|
64
|
|
|
133
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('Metadata'); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::Condition { |
|
137
|
14
|
|
|
14
|
|
72533
|
use Moose::Role; |
|
|
14
|
|
|
|
|
38
|
|
|
|
14
|
|
|
|
|
71
|
|
|
138
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('Condition'); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::Output { |
|
142
|
14
|
|
|
14
|
|
73037
|
use Moose::Role; |
|
|
14
|
|
|
|
|
39
|
|
|
|
14
|
|
|
|
|
72
|
|
|
143
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('Output'); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::PostOutput { |
|
147
|
14
|
|
|
14
|
|
71938
|
use Moose::Role; |
|
|
14
|
|
|
|
|
35
|
|
|
|
14
|
|
|
|
|
70
|
|
|
148
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('PostOutput'); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::Attached { |
|
152
|
14
|
|
|
14
|
|
74201
|
use Moose::Role; |
|
|
14
|
|
|
|
|
34
|
|
|
|
14
|
|
|
|
|
72
|
|
|
153
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('Attached'); |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
package CCfnX::Meta::Attribute::Trait::Attachable { |
|
157
|
14
|
|
|
14
|
|
75911
|
use Moose::Role; |
|
|
14
|
|
|
|
|
32
|
|
|
|
14
|
|
|
|
|
60
|
|
|
158
|
14
|
|
|
14
|
|
78486
|
use CCfnX::Deployment; |
|
|
14
|
|
|
|
|
45
|
|
|
|
14
|
|
|
|
|
3292
|
|
|
159
|
|
|
|
|
|
|
Moose::Util::meta_attribute_alias('Attachable'); |
|
160
|
|
|
|
|
|
|
has type => (is => 'ro', isa => 'Str', required => 1); |
|
161
|
|
|
|
|
|
|
has generates_params => (is => 'ro', isa => 'ArrayRef[Str]', required => 1); |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub get_info { |
|
164
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $key) = @_; |
|
165
|
0
|
0
|
|
|
|
|
die "Please specify a name for Attachment " . $self->name if (not defined $name); |
|
166
|
0
|
|
|
|
|
|
my $dep = CCfnX::Deployment->new_with_roles({ name => $name }, 'CCfnX::CloudFormationDeployer', 'CCfnX::PersistentDeployment'); |
|
167
|
0
|
|
|
|
|
|
$dep->get_from_mongo; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
|
my $output; |
|
170
|
0
|
|
|
|
|
|
eval { $output = $dep->output($key) }; |
|
|
0
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return $output; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |