| 1 | package AWS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 0 | ▶ | sub AccountId { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AccountId: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 0 | return { Ref => 'AWS::AccountId' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 0 | ▶ | sub NotificationARNs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NotificationARNs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 0 | return { Ref => 'AWS::NotificationARNs' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub NoValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
NoValue: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | return { Ref => 'AWS::NoValue' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub Region { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Region: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | return { Ref => 'AWS::Region' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | sub StackId { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StackId: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | return { Ref => 'AWS::StackId' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | ▶ | sub StackName { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
StackName: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | return { Ref => 'AWS::StackName' }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | package Fn; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 15 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub Join { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Join: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | my ($with, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | return { 'Fn::Join' => [ $with, [ @args ] ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub ImportValue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ImportValue: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | return { "Fn::ImportValue" => $value }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub Split { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Split: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my ($delimiter, $string) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | return { "Fn::Split" => [ $delimiter, $string ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub FindInMap { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FindInMap: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my ($map_name, @keys) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | return { "Fn::FindInMap" => [ $map_name, @keys ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | sub Sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Sub: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | my ($string, @vars) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if (@vars) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return { "Fn::Sub" => [ $string, { @vars } ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | return { "Fn::Sub" => $string }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | ▶ | sub Base64 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Base64: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | my ($what) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | return { "Fn::Base64" => $what }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub GetAZs { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetAZs: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return { "Fn::GetAZs" => "" }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub Select { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Select: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | my ($index, $array) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return { "Fn::Select" => [ $index, $array ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub Equals { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Equals: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | my $value1 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | my $value2 = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | die "Fn::Equals only admits two parameters" if (@_ > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return { "Fn::Equals" => [ $value1, $value2 ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub Not { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Not: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $condition = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | die "Fn::Equals only admits one parameter" if (@_ > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | return { "Fn::Not" => [ $condition ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | sub If { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
If: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $condition_name = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my $value_true = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | my $value_false = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | die "Fn::If only admits three parameters" if (@_ > 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | return { "Fn::If" => [ $condition_name, $value_true, $value_false ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | sub Or { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Or: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my @conditions = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | return { 'Fn::Or' => [ @conditions ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | sub Cidr { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Cidr: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ($ipblock, $count, $sizemask) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if (defined $sizemask) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return { 'Fn::Cidr' => [ $ipblock, $count, $sizemask ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return { 'Fn::Cidr' => [ $ipblock, $count ] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # Generates { "Fn::Transform" : { "Name" : macro name, "Parameters" : {key : value, ... } } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub Transform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Transform: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my ($macro_name, $params) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | return { 'Fn::Transform' => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | name => $macro_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | parameters => $params, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | package CCfnX::Shortcuts; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 15 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 15 | ▶ | use Moose::Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 15 | ▶ | use Regexp::Common qw(net); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 15 | ▶ | use LWP::Simple; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 15 | ▶ | use JSON::MaybeXS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 15 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 15 | ▶ | use CCfnX::DSL::Inheritance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 15 | our $ubuntu_release_table_url = 'https://cloud-images.ubuntu.com/locator/ec2/releasesTable'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 15 | Moose::Exporter->setup_import_methods( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | with_meta => [ 'resource', 'output', 'condition', 'mapping', 'metadata', 'stack_version', 'transform' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | as_is => [ qw/Ref ConditionRef GetAtt UserData CfString Parameter Attribute FindImage Json | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | Tag GetPolicy ELBListener TCPELBListener SGRule SGEgressRule | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | GetASGStatus GetInstanceStatus FindUbuntuImage FindBaseImage SpecifyInSubClass/ ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | sub transform { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | Moose->throw_error('Usage: transform name1, name2, ... , nameN;') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | if ( @_ < 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my ( $meta, @transforms ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ( $meta->find_attribute_by_name('transform') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | die "There is already a transform element in the template"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Allow just one of this to be declared | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 'transform_spec', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | isa => 'ArrayRef[Str]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | traits => ['Transform'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | default => sub { \@transforms }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub condition { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
condition: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | Moose->throw_error('Usage: output \'name\' => Ref|GetAtt|{}') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | if (@_ != 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | my ( $meta, $name, $condition ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ($meta->find_attribute_by_name($name)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | die "Redeclared resource/output/condition/mapping $name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | isa => "Cfn::Value", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | traits => [ 'Condition' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $condition; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 83 | ▶ | sub resource { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resource: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # TODO: Adjust this error condition to better detect incorrect num of params passed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 83 | ▶ | Moose->throw_error('Usage: resource \'name\' => \'Type\', { key => value, ... }[, { DependsOn => ... }]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ != 4 and @_ != 5
MC/DC0%0/2
@_ != 4 and @_ != 5
@_ != 4
@_ != 5
Truth table66%2/3
A and B
A= @_ != 4B= @_ != 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | if (@_ != 4 and @_ != 5); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 83 | my ( $meta, $name, $resource, $options, $extra ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 83 | ▶ | $extra = {} if (not defined $extra); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 83 | my %args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 83 | ▶ | if (ref($options) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | %args = &$options(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } elsif (ref($options) eq 'HASH'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 82 | %args = %$options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 83 | my $res_isa; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 83 | ▶ | if ($resource =~ m/^Custom::/){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | $res_isa = "Cfn::Resource::AWS::CloudFormation::CustomResource"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 82 | $res_isa = "Cfn::Resource::$resource"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 83 | my $default_coderef = resolve_resource_inheritance_dsl({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | meta => $meta, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | resource => $resource, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | attr_family => 'CCfnX::Meta::Attribute::Trait::Resource', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | properties => \%args, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | extra => $extra, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 82 | $meta->add_attribute( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | isa => $res_isa, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | traits => [ 'Resource' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | default => $default_coderef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | ▶ | sub output { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: called CC=6 SCAR=21.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | ▶ | Moose->throw_error('Usage: output \'name\' => Ref|GetAtt|{}[, { Condition => ... }]') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ lt 3 and @_ gt 5
MC/DC0%0/2
@_ lt 3 and @_ gt 5
@_ lt 3
@_ gt 5
Truth table33%1/3
A and B
A= @_ lt 3B= @_ gt 5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | if ( @_ lt 3 and @_ gt 5 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | my ( $meta, $name, $options, $extra ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | ▶ | if ($meta->find_attribute_by_name($name)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | die "Redeclared resource/output/condition/mapping $name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 4 | ▶ | $extra = {} if (not defined $extra); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 4 | ▶ | if (my ($att) = ($name =~ m/^\+(.*)/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | $att, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | isa => 'Cfn::Output', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | traits => [ 'Output', 'PostOutput' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return Moose::Util::TypeConstraints::find_type_constraint('Cfn::Output')->coerce({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | Value => $options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | %$extra } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | isa => 'Cfn::Output', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | traits => [ 'Output' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 4 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | return Moose::Util::TypeConstraints::find_type_constraint('Cfn::Output')->coerce({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | Value => $options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | %$extra } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub mapping { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mapping: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | Moose->throw_error('Usage: mapping \'name\' => { key => value, ... }') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | if (@_ != 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | my ( $meta, $name, $options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | if ($meta->find_attribute_by_name($name)){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | die "Redeclared resource/output/condition/mapping $name"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my %args = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if (ref($options) eq 'CODE'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | %args = &$options(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } elsif (ref($options) eq 'HASH'){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | %args = %$options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | isa => 'Cfn::Mapping', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | traits => [ 'Mapping' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | return Moose::Util::TypeConstraints::find_type_constraint('Cfn::Mapping')->coerce({ %args }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 4 | ▶ | sub metadata { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
metadata: called CC=3 SCAR=12.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 4 | ▶ | Moose->throw_error('Usage: metadata \'name\' => {json-object}') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | if (@_ != 3); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 4 | my ( $meta, $name, @options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 4 | ▶ | if (my ($att) = ($name =~ m/^\+(.*)/)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | $att, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | isa => 'Cfn::Value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | traits => [ 'Metadata' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | return Moose::Util::TypeConstraints::find_type_constraint('Cfn::Value')->coerce(@options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | isa => 'Cfn::Value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | traits => [ 'Metadata' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 4 | ▶ | default => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 4 | return Moose::Util::TypeConstraints::find_type_constraint('Cfn::Value')->coerce(@options); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | sub stack_version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stack_version: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | Moose->throw_error('Usage: stack_version \'version\'') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | if (@_ != 2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my ( $meta, $version ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | $meta->add_attribute( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 'StackVersion', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | isa => 'Cfn::Value', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | coerce => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | traits => [ 'Metadata' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | default => sub { return $version }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # Moose->throw_error('Usage: resource \'name\' => ( key => value, ... )') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # if @_ % 2 == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # my %context = Moose::Util::_caller_info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # $context{context} = 'resource declaration'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # $context{type} = 'class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # my %options = ( definition_context => \%context, @_ ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # my $attrs = ( ref($name) eq 'ARRAY' ) ? $name : [ ($name) ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # $meta->add_attribute( $_, is => 'rw', isa => 'AWS::EC2::Instance', lazy => 1, %options ) for @$attrs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | sub GetPolicy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetPolicy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | die "Must specify an exported policy" unless defined $param; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | return CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | return @{ $_[0]->params->$param->{Policy} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 19 | ▶ | sub Parameter { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Parameter: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | # When CCfnX::Shortcuts is attached to a class, it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | # overrides the Parameters method of Cfn without warning, making $cfn->Parameter('') return unexpected | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | # things. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | # This "if" is a hack to detect when Parameters is being called as a method ($_[0] is a ref) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | # or if it's being called as a shortcut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | # TODO: decide how to fix the fact that Cfn has a Parameters method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 19 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 8 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 8 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # Setter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 4 | ▶ | $self->Parameters({}) if (not defined $self->Parameters); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 4 | $self->Parameters->{ $key } = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # Getter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 4 | ▶ | return $self->Parameters->{ $key } if (defined $self->Parameters); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 15 | my $param = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 15 | ▶ | die "Must specify a parameter to read from" if (not defined $param); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 9 | ▶ | return CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 9 | my $cfn = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 9 | ▶ | Moose->throw_error("DynamicValue didn't get it's context") if (not defined $cfn); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 9 | return $cfn->params->$param | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 5 | ▶ | sub Attribute { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Attribute: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 5 | my $path = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 5 | my ($attribute, $method, $rest) = split /\./, $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 5 | ▶ | croak "Don't understand attributes with more than two path elements" if (defined $rest); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 5 | ▶ | croak "Must specify an attribute read from" if (not defined $attribute); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 5 | ▶ | if (not defined $method) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 2 | ▶ | return CCfnX::DynamicValue->new(Value => sub { return $_[0]->$attribute }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | ▶ | return CCfnX::DynamicValue->new(Value => sub { return $_[0]->$attribute->$method }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub SpecifyInSubClass { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SpecifyInSubClass: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | return CCfnX::DynamicValue->new(Value => sub { die "You must specify a value" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 2 | ▶ | sub Tag { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | my ($tag_key, $tag_value, %rest) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 2 | { Key => $tag_key, Value => $tag_value, %rest }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 60 | ▶ | sub Ref { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Ref: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 60 | my $ref = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 60 | ▶ | die "Ref expected a logical name to reference to" if (not defined $ref); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 60 | return { Ref => $ref }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | sub ConditionRef { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ConditionRef: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $condition = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | die "Condition expected a logical name to reference to" if (not defined $condition); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return { Condition => $condition }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub Json { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Json: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my $json = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | return decode_json($json); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 8 | ▶ | sub GetAtt { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetAtt: called CC=3 SCAR=12.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 8 | my ($ref, $property) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 8 | ▶ | die "GetAtt expected a logical name and a property name" if (not defined $ref or not defined $property); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $ref and defined $property
MC/DC0%0/2
defined $ref and defined $property
defined $ref
defined $property
Truth table33%1/3
A and B
A= defined $refB= defined $property
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 8 | { 'Fn::GetAtt' => [ $ref, $property ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | sub ELBListener { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ELBListener: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my ($lbport, $lbprotocol, $instanceport, $instanceprotocol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | die "no port for ELB listener passed" if (not defined $lbport); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | die "no protocol for ELB listener passed" if (not defined $lbprotocol); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | $instanceport = $lbport if (not defined $instanceport); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | $instanceprotocol = $lbprotocol if (not defined $instanceprotocol); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | return { InstancePort => $instanceport, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | InstanceProtocol => $instanceprotocol, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | LoadBalancerPort => $lbport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | Protocol => $lbprotocol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | sub TCPELBListener { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TCPELBListener: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my ($lbport, $instanceport) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | return ELBListener($lbport, 'TCP', $instanceport); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # Creates a rule for a security group: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # IF port is a number, it opens just that port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # IF port is a range: number-number, it opens that port range | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | # to: where to open the rule to. If this looks like a CIDR, it will populate CidrIP in the rule, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | # else, it will populate SourceSecurityGroupId. (This means that you can't use this shortcut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | # to open a SG to a Ref(...) in a parameter, for example). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | # proto: if specified, uses that protocol. If not, TCP by default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 15 | ▶ | sub SGRule { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SGRule: called CC=14 SCAR=28.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 15 | my ($port, $to, $proto_or_desc, $desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 15 | my $proto; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 15 | ▶ | if (defined($proto_or_desc)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 13 | ▶ | if ($proto_or_desc eq 'tcp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp" or $proto_or_desc eq "icmp" or &looks_like_number($proto_or_desc)
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp" or $proto_or_desc eq "icmp"
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp"
MC/DC0%0/4
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp" or $proto_or_desc eq "icmp" or &looks_like_number($proto_or_desc)
$proto_or_desc eq "tcp"
$proto_or_desc eq "udp"
$proto_or_desc eq "icmp"
&looks_like_number($proto_or_desc)
Truth table40%2/5
A or B or C or D
A= $proto_or_desc eq "tcp"B= $proto_or_desc eq "udp"C= $proto_or_desc eq "icmp"D= &looks_like_number($proto_or_desc)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | or $proto_or_desc eq 'udp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | or $proto_or_desc eq 'icmp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | or looks_like_number($proto_or_desc)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 13 | $proto = $proto_or_desc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $proto = 'tcp'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $desc = $proto_or_desc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 15 | my ($from_port, $to_port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 15 | ▶ | if ($port =~ m/\-/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 4 | ▶ | if ($port eq '-1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 4 | ($from_port, $to_port) = (-1, -1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ($from_port, $to_port) = split /\-/, $port, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 11 | ($from_port, $to_port) = ($port, $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 15 | ▶ | $proto = 'tcp' if (not defined $proto); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 15 | my $rule = { IpProtocol => $proto, FromPort => $from_port, ToPort => $to_port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 15 | ▶ | $rule->{ Description } = $desc if (defined $desc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 15 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | # Rules to detect when we're trying to open to a CIDR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # If $to is a reference, it means that it is either: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # - A CloudDeploy Ref of another resource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # - A CCfnX::DynamicValue object (usually coming from a Parameter()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # In both cases, it ends up pointing to a SG identifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | # If $to is an IP address, it will come in form of a string (scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # hence falling back to a SSGroupId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 15 | ▶ | unless (ref($to)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 10 | ▶ | $key = 'CidrIp' if ($to =~ m/$RE{net}{IPv4}/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 10 | ▶ | $key = 'CidrIpv6' if ($to =~ m/$RE{net}{IPv6}/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | # Fallback to SSGroupId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 15 | ▶ | $key = 'SourceSecurityGroupId' if (not defined $key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 15 | $rule->{ $key } = $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 15 | return $rule; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | sub SGEgressRule { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SGEgressRule: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my ($port, $to, $proto_or_desc, $desc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $proto; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | if (defined($proto_or_desc)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ($proto_or_desc eq 'tcp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp" or $proto_or_desc eq "icmp" or &looks_like_number($proto_or_desc)
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp" or $proto_or_desc eq "icmp"
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp"
MC/DC0%0/4
$proto_or_desc eq "tcp" or $proto_or_desc eq "udp" or $proto_or_desc eq "icmp" or &looks_like_number($proto_or_desc)
$proto_or_desc eq "tcp"
$proto_or_desc eq "udp"
$proto_or_desc eq "icmp"
&looks_like_number($proto_or_desc)
Truth table0%0/5
A or B or C or D
A= $proto_or_desc eq "tcp"B= $proto_or_desc eq "udp"C= $proto_or_desc eq "icmp"D= &looks_like_number($proto_or_desc)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | or $proto_or_desc eq 'udp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | or $proto_or_desc eq 'icmp' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | or looks_like_number($proto_or_desc)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $proto = $proto_or_desc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $proto = 'tcp'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $desc = $proto_or_desc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | my ($from_port, $to_port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ($port =~ m/\-/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | if ($port eq '-1') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ($from_port, $to_port) = (-1, -1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ($from_port, $to_port) = split /\-/, $port, 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ($from_port, $to_port) = ($port, $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | $proto = 'tcp' if (not defined $proto); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | my $rule = { IpProtocol => $proto, FromPort => $from_port, ToPort => $to_port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | $rule->{ Description } = $desc if (defined $desc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | my $key; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # Rules to detect when we're trying to open to a CIDR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # If $to is a reference, it means that it is either: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # - A CloudDeploy Ref of another resource | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | # - A CCfnX::DynamicValue object (usually coming from a Parameter()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | # In both cases, it ends up pointing to a SG identifier. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # If $to is an IP address, it will come in form of a string (scalar) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # hence falling back to a SSGroupId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | unless (ref($to)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | $key = 'CidrIp' if ($to =~ m/$RE{net}{IPv4}/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | ▶ | $key = 'CidrIpv6' if ($to =~ m/$RE{net}{IPv6}/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | # Fallback to SSGroupId | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | $key = 'DestinationSecurityGroupId' if (not defined $key); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $rule->{ $key } = $to; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | return $rule; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | ▶ | sub FindImage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FindImage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my ($name, %criterion) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | require CloudDeploy::AMIDB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | ▶ | return CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my $amidb = CloudDeploy::AMIDB->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | if (ref($name) and $name->isa('CCfnX::DynamicValue')){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $name and $name->isa("CCfnX::DynamicValue")
MC/DC0%0/2
ref $name and $name->isa("CCfnX::DynamicValue")
ref $name
$name->isa("CCfnX::DynamicValue")
Truth table0%0/3
A and B
A= ref $nameB= $name->isa("CCfnX::DynamicValue")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $name = $name->to_value($self)->Value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | foreach my $key (keys %criterion) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if(ref($criterion{$key}) and $criterion{$key}->isa('CCfnX::DynamicValue')){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $criterion{$key} and $criterion{$key}->isa("CCfnX::DynamicValue")
MC/DC0%0/2
ref $criterion{$key} and $criterion{$key}->isa("CCfnX::DynamicValue")
ref $criterion{$key}
$criterion{$key}->isa("CCfnX::DynamicValue")
Truth table0%0/3
A and B
A= ref $criterion{$key}B= $criterion{$key}->isa("CCfnX::DynamicValue")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | $criterion{$key} = $criterion{$key}->to_value($self)->Value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | $amidb->find( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | Account => CloudDeploy::Config->new->account, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | Region => $self->params->region, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | Name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | %criterion | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | )->prop('ImageId'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | ▶ | sub _extract_ami_from_uri { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_extract_ami_from_uri: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | my $uri = shift || confess "Need URI"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || confess('Need URI')
MC/DC0%0/1
shift() || confess('Need URI')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | $uri =~ m{<a.*href.*>([\s\S]+?)</a>}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | return $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | # NOTE: Only hvm:ebs-ssd supported! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | sub FindUbuntuImage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FindUbuntuImage: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | my $region = shift || confess "Need Region"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || confess('Need Region')
MC/DC0%0/1
shift() || confess('Need Region')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | my $version = shift || confess "Need Version"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || confess('Need Version')
MC/DC0%0/1
shift() || confess('Need Version')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $raw = get $ubuntu_release_table_url; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | die "Could not get Ubuntu release information" unless defined $raw; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | my $json = JSON->new->utf8->relaxed(1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | my $info = $json->decode($raw)->{aaData}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | my @h = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | _extract_ami_from_uri($_->[6]) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | } grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | $_->[0] eq $region && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$_->[0] eq $region && $_->[1] eq $version && $_->[3] eq 'amd64' && $_->[4] eq 'hvm:ebs-ssd'
$_->[0] eq $region and $_->[1] eq $version and $_->[3] eq "amd64"
$_->[0] eq $region and $_->[1] eq $version
MC/DC0%0/4
$_->[0] eq $region && $_->[1] eq $version && $_->[3] eq 'amd64' && $_->[4] eq 'hvm:ebs-ssd'
$_->[0] eq $region
$_->[1] eq $version
$_->[3] eq "amd64"
$_->[4] eq 'hvm:ebs-ssd'
Truth table0%0/5
A and B and C && D
A= $_->[0] eq $regionB= $_->[1] eq $versionC= $_->[3] eq "amd64"D= $_->[4] eq 'hvm:ebs-ssd'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | $_->[1] eq $version && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | $_->[3] eq 'amd64' && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | $_->[4] eq 'hvm:ebs-ssd' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } @$info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | if (scalar @h > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 0 | confess "Got more than a single AMI!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } elsif (scalar @h == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | confess "Did not find an image for '$version' in region '$region'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | return shift @h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | sub FindBaseImage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
FindBaseImage: not called CC=2 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | my $region = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | my @filters = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 15 | ▶ | use DateTime::Format::Strptime qw( ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | my @describe_images_filter = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | my ( $name, $value ) = split( '=', $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | { Name => $name, Values => [$value] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | } @filters; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my $ec2 = Paws->service( 'EC2', region => $region ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | my @amis = @{ $ec2->DescribeImages( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | Filters => \@describe_images_filter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | )->Images }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | # print "\n\n Unsorted list of amis: \n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # foreach my $ami (@amis) { printf( "%s - %s\n", $ami->ImageId, $ami->CreationDate ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | my @sorted_amis = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | my $format = DateTime::Format::Strptime->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | pattern => '%Y-%m-%dT%T', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | time_zone => 'UTC', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | on_error => 'croak', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | strict => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | my $dta = $format->parse_datetime( $a->CreationDate ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | my $dtb = $format->parse_datetime( $b->CreationDate ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | # Reversed sort so the latest one ends up in position 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $dtb <=> $dta | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } @amis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | # print "\n\n Sorted list of amis: \n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # foreach my $ami (@sorted_amis) { printf( "%s - %s\n", $ami->ImageId, $ami->CreationDate ) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my $ami = $sorted_amis[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | ▶ | die "FindBaseImage: Couldn't find any image that match the specified filters\n" if not defined $ami; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | warn sprintf( "FindBaseImage: using '%s' with ID '%s' as the base image (created at %s)\n", $ami->Name, $ami->ImageId, $ami->CreationDate ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | return $ami->ImageId; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | sub OSImage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
OSImage: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 0 | require CloudDeploy::AMIDB; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 15 | ▶ | use CCfnX::UserData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 4 | ▶ | sub UserData { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
UserData: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 4 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 4 | ▶ | return CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 4 | my @ctx = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 4 | CCfnX::UserData->new(text => $args[0])->as_hashref(@ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 4 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 4 | ▶ | sub CfString { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CfString: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 4 | my $string = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 4 | ▶ | return CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 4 | my @ctx = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 4 | CCfnX::UserData->new(text => $string)->as_hashref_joins(@ctx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 4 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | ▶ | sub GetASGStatus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetASGStatus: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | my ($asg_name, %defaults) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | require Paws; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | my %dyn_values = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | foreach my $property (keys %defaults) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | $dyn_values{ $property } = CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $stack_name = $self->params->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | ▶ | if ($self->params->update) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | #return get_asg_info($self->params->region, $stack_name, $asg_name, $property) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | my $resources = $self->stash->{ cfn_resources }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | ▶ | if (not defined $resources) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 0 | my $res_array = Paws->service('CloudFormation', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | region => $self->params->region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | )->DescribeStackResources(StackName => $stack_name)->StackResources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | $resources = { map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | ($_->LogicalResourceId => $_ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | } @$res_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | $self->add_to_stash('cfn_resources', $resources); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 0 | my $asg = $self->stash->{ $asg_name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | ▶ | if (not defined $asg){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | my $asg_physid = $resources->{ $asg_name }->PhysicalResourceId; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | $asg = Paws->service('AutoScaling', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | region => $self->params->region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | )->DescribeAutoScalingGroups(AutoScalingGroupNames => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | $asg_physid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | ▶ | die "Didn't find autoscaling group $asg_physid" if (scalar(@{ $asg->AutoScalingGroups } == 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | $asg = $asg->AutoScalingGroups->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 0 | $self->add_to_stash($asg_name, $asg); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 0 | return $asg->$property; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | return $defaults{ $property } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | return %dyn_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | sub GetInstanceStatus { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
GetInstanceStatus: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | my ($instance_name, %defaults) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | require Paws; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | my %dyn_values = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | foreach my $property (keys %defaults) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | $dyn_values{ $property } = CCfnX::DynamicValue->new(Value => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | my $stack_name = $self->params->name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | if ($self->params->update) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | my $resources = $self->stash->{ cfn_resources }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | ▶ | if (not defined $resources) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | my $res_array = Paws->service('CloudFormation', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | region => $self->params->region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | )->DescribeStackResources(StackName => $stack_name)->StackResources; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | $resources = { map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 0 | ($_->LogicalResourceId => $_ ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } @$res_array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | $self->add_to_stash('cfn_resources', $resources); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | my $instance = $self->stash->{ $instance_name }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | ▶ | if (not defined $instance){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $instance_physid = $resources->{ $instance_name }->PhysicalResourceId; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | $instance = Paws->service('EC2', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | region => $self->params->region | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | )->DescribeInstances(InstanceIds => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | $instance_physid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | ]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | ▶ | die "Didn't find instance $instance_physid" if (scalar(@{ $instance->Reservations } == 0)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | $instance = $self->stash->{ instance } = $instance->Reservations->[0]->Instances->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 0 | $self->add_to_stash($instance_name, $instance); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | return $instance->$property; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | return $defaults{ $property } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | return %dyn_values; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||