| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package AWS::CloudFront::Distribution; |
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use VSO; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
1
|
|
|
1
|
|
774
|
use AWS::CloudFront::OriginAccessIdentity; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
has 'cf' => ( |
|
8
|
|
|
|
|
|
|
is => 'ro', |
|
9
|
|
|
|
|
|
|
isa => 'AWS::CloudFront', |
|
10
|
|
|
|
|
|
|
required => 1, |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'Id' => ( |
|
14
|
|
|
|
|
|
|
is => 'ro', |
|
15
|
|
|
|
|
|
|
isa => 'Str', |
|
16
|
|
|
|
|
|
|
required => 1, |
|
17
|
|
|
|
|
|
|
); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has 'Status' => ( |
|
20
|
|
|
|
|
|
|
is => 'ro', |
|
21
|
|
|
|
|
|
|
isa => 'Str', |
|
22
|
|
|
|
|
|
|
required => 1, |
|
23
|
|
|
|
|
|
|
where => sub { |
|
24
|
|
|
|
|
|
|
m{^(?:Deployed|InProgress)$} |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'LastModifiedTime' => ( |
|
29
|
|
|
|
|
|
|
is => 'ro', |
|
30
|
|
|
|
|
|
|
isa => 'Maybe[Str]', |
|
31
|
|
|
|
|
|
|
where => sub { |
|
32
|
|
|
|
|
|
|
# eg: 2011-05-05T21:11:39.546Z |
|
33
|
|
|
|
|
|
|
m{^(?:\d\d\d\d-\d\d-\d\dT\d+:\d\d:\d\d\.\d+Z)$} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'InProgressValidationBatches' => ( |
|
38
|
|
|
|
|
|
|
is => 'ro', |
|
39
|
|
|
|
|
|
|
isa => 'Int', |
|
40
|
|
|
|
|
|
|
required => 0, |
|
41
|
|
|
|
|
|
|
default => sub { 0 } |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'DomainName' => ( |
|
45
|
|
|
|
|
|
|
is => 'rw', |
|
46
|
|
|
|
|
|
|
isa => 'Str', |
|
47
|
|
|
|
|
|
|
required => 1, |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
has 'ActiveTrustedSigners' => ( |
|
51
|
|
|
|
|
|
|
is => 'ro', |
|
52
|
|
|
|
|
|
|
isa => 'ArrayRef[AWS::CloudFront::ActiveTrustedSigner]', |
|
53
|
|
|
|
|
|
|
required => 0, |
|
54
|
|
|
|
|
|
|
); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has 'Origin' => ( |
|
57
|
|
|
|
|
|
|
is => 'ro', |
|
58
|
|
|
|
|
|
|
isa => 'AWS::CloudFront::S3Origin|AWS::CloudFront::CustomOrigin', |
|
59
|
|
|
|
|
|
|
required => 1, |
|
60
|
|
|
|
|
|
|
); |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
has 'CallerReference' => ( |
|
63
|
|
|
|
|
|
|
is => 'ro', |
|
64
|
|
|
|
|
|
|
isa => 'Str', |
|
65
|
|
|
|
|
|
|
required => 1, |
|
66
|
|
|
|
|
|
|
lazy => 1, |
|
67
|
|
|
|
|
|
|
default => sub { |
|
68
|
|
|
|
|
|
|
my $s = shift; |
|
69
|
|
|
|
|
|
|
$s->cf->distribution( Id => $s->Id )->CallerReference |
|
70
|
|
|
|
|
|
|
}, |
|
71
|
|
|
|
|
|
|
); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
has 'CNAME' => ( |
|
74
|
|
|
|
|
|
|
is => 'rw', |
|
75
|
|
|
|
|
|
|
isa => 'Str', |
|
76
|
|
|
|
|
|
|
required => 0, |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has 'Comment' => ( |
|
80
|
|
|
|
|
|
|
is => 'ro', |
|
81
|
|
|
|
|
|
|
isa => 'Str', |
|
82
|
|
|
|
|
|
|
required => 0, |
|
83
|
|
|
|
|
|
|
); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
has 'Enabled' => ( |
|
86
|
|
|
|
|
|
|
is => 'rw', |
|
87
|
|
|
|
|
|
|
isa => 'Bool', |
|
88
|
|
|
|
|
|
|
required => 1, |
|
89
|
|
|
|
|
|
|
); |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has 'DefaultRootObject' => ( |
|
92
|
|
|
|
|
|
|
is => 'rw', |
|
93
|
|
|
|
|
|
|
isa => 'Str', |
|
94
|
|
|
|
|
|
|
required => 0, |
|
95
|
|
|
|
|
|
|
); |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
has 'Logging' => ( |
|
98
|
|
|
|
|
|
|
is => 'ro', |
|
99
|
|
|
|
|
|
|
isa => 'AWS::CloudFront::Logging', |
|
100
|
|
|
|
|
|
|
required => 0, |
|
101
|
|
|
|
|
|
|
); |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
has 'TrustedSigners' => ( |
|
104
|
|
|
|
|
|
|
is => 'ro', |
|
105
|
|
|
|
|
|
|
isa => 'ArrayRef[AWS::CloudFront::TrustedSigner]', |
|
106
|
|
|
|
|
|
|
required => 0, |
|
107
|
|
|
|
|
|
|
); |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has 'OriginAccessIdentity' => ( |
|
110
|
|
|
|
|
|
|
is => 'ro', |
|
111
|
|
|
|
|
|
|
isa => 'Maybe[AWS::CloudFront::OriginAccessIdentity]', |
|
112
|
|
|
|
|
|
|
required => 0, |
|
113
|
|
|
|
|
|
|
lazy => 1, |
|
114
|
|
|
|
|
|
|
default => sub { |
|
115
|
|
|
|
|
|
|
my $s = shift; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
foreach my $ident ( $s->cf->origin_access_identities ) |
|
118
|
|
|
|
|
|
|
{ |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
}# end foreach() |
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub update |
|
126
|
|
|
|
|
|
|
{ |
|
127
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $type = 'UpdateDistribution'; |
|
130
|
0
|
|
|
|
|
|
my $response = $s->cf->request( $type, Distribution => $s )->request(); |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
if( $response->error_code ) |
|
133
|
|
|
|
|
|
|
{ |
|
134
|
0
|
|
|
|
|
|
die $response->msg; |
|
135
|
|
|
|
|
|
|
}# end if() |
|
136
|
|
|
|
|
|
|
}# end update() |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub delete |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
0
|
|
|
0
|
0
|
|
my $s = shift; |
|
142
|
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $type = 'DeleteDistribution'; |
|
144
|
0
|
|
|
|
|
|
my $response = $s->cf->request( $type, Id => $s->Id )->request(); |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
0
|
|
|
|
|
if( $response->error_code ) |
|
147
|
|
|
|
|
|
|
{ |
|
148
|
0
|
|
|
|
|
|
die $response->msg; |
|
149
|
|
|
|
|
|
|
}# end if() |
|
150
|
|
|
|
|
|
|
}# end delete() |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub create_origin_access_identity |
|
154
|
|
|
|
|
|
|
{ |
|
155
|
0
|
|
|
0
|
0
|
|
my ($s, %args) = @_; |
|
156
|
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
my $type = 'CreateOriginAccessIdentity'; |
|
158
|
0
|
|
|
|
|
|
my $response = $s->cf->request( $type, |
|
159
|
|
|
|
|
|
|
CallerReference => $s->CallerReference, |
|
160
|
|
|
|
|
|
|
Comment => $args{Comment} |
|
161
|
|
|
|
|
|
|
)->request(); |
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
|
|
|
if( $response->error_code ) |
|
164
|
|
|
|
|
|
|
{ |
|
165
|
0
|
|
|
|
|
|
die $response->msg; |
|
166
|
|
|
|
|
|
|
}# end if() |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $xpc = $response->xpc; |
|
169
|
0
|
0
|
|
|
|
|
if( my ($node) = $xpc->findnodes('.//cf:CloudFrontOriginAccessIdentity') ) |
|
|
|
0
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
{ |
|
171
|
0
|
|
|
|
|
|
return AWS::CloudFront::OriginAccessIdentity->new( |
|
172
|
|
|
|
|
|
|
Id => $xpc->findvalue('.//cf:Id', $node), |
|
173
|
|
|
|
|
|
|
S3CanonicalUserId => $xpc->findvalue('.//cf:S3CanonicalUserId', $node), |
|
174
|
|
|
|
|
|
|
CallerReference => $xpc->findvalue('.//cf:CallerReference', $node), |
|
175
|
|
|
|
|
|
|
Location => $response->response->header('Location'), |
|
176
|
|
|
|
|
|
|
); |
|
177
|
|
|
|
|
|
|
} |
|
178
|
|
|
|
|
|
|
elsif( my ($error) = $xpc->findnodes('.//cf:Error') ) |
|
179
|
|
|
|
|
|
|
{ |
|
180
|
0
|
0
|
|
|
|
|
if( my ($code) = $response->response->content =~ m{(.+?)}s ) |
|
181
|
|
|
|
|
|
|
{ |
|
182
|
|
|
|
|
|
|
# The origin already exists or some other error. |
|
183
|
0
|
|
|
|
|
|
die $code; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
else |
|
186
|
|
|
|
|
|
|
{ |
|
187
|
0
|
|
|
|
|
|
die "Invalid response: ", $response->response->content; |
|
188
|
|
|
|
|
|
|
}# end if() |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
else |
|
191
|
|
|
|
|
|
|
{ |
|
192
|
0
|
|
|
|
|
|
die "Invalid response: ", $response->response->content; |
|
193
|
|
|
|
|
|
|
}# end if() |
|
194
|
|
|
|
|
|
|
}# end create_origin_access_identity() |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1;# return true: |
|
197
|
|
|
|
|
|
|
|