CCfnX/MakeAMIBaseVPC.pm

filter: Statementstmt 94.2% 49 / 52 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 0.0% 0 / 1 totaltotal 87.3% 62 / 71 CC 5 SCAR 9.7
CC
5
Cov
88%
BUILD
5.4
__ANON__
2.0
BEGIN
1.0
CRAP 2.6
« CloudDeploy/CommandLine/Template.pm ↑ Summary CCfnX/ConsoleDeployer.pm »
1 1 ▶use Cfn;
Subroutine BEGIN: called CC=1 SCAR=0.0
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 package CCfnX::MakeAMIBaseVPCArgs {
6 1 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 extends 'CCfnX::MakeAMIArgs';
8 1 ▶ use CCfnX::Attachments;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 0 ▶ has '+region' => (lazy => 1, default => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
11 0 my $self = shift;
12 0 return $self->VPCRegion;
13 1 });
14  
15 1 attachment Network => (type => 'Standard::BaseNetwork', documentation => 'Network to spawn the AMI in', provides => {
16 AZ1 => 'net/public/0/id',
17 AZ1az => 'net/public/0/az',
18 VPC => 'vpc/id',
19 VPCRegion => 'vpc/region',
20 });
21 }
22  
23 1 package CCfnX::MakeAMIBaseVPC {
24 1 ▶ use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 1 extends 'CCfn';
26 1 ▶ use CCfnX::CreateAMIUserData;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶ use CCfnX::UserData;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 1 ▶ use CCfnX::Shortcuts;
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 1 resource CfnUser => 'AWS::IAM::User', {
31 Path => '/',
32 };
33  
34 1 resource CfnPolicy => 'AWS::IAM::Policy', {
35 PolicyName => 'AbilityToGetMetadata',
36 Roles => [ Ref('CfnRole') ],
37 Users => [ Ref('CfnUser') ],
38 PolicyDocument => {
39 Statement => [ {
40 Effect => "Allow",
41 Action => "cloudformation:DescribeStackResource",
42 Resource => "*"
43 }, ]
44 },
45 };
46  
47 1 resource CfnRole => 'AWS::IAM::Role', {
48 Path => '/',
49 AssumeRolePolicyDocument => {
50 Statement => [ {
51 Effect => 'Allow',
52 Principal => { Service => [ 'ec2.amazonaws.com' ] },
53 Action => [ 'sts:AssumeRole' ]
54 } ]
55 },
56 };
57  
58 1 resource CfnInstanceProfile => 'AWS::IAM::InstanceProfile', {
59 Path => '/',
60 Roles => [ Ref('CfnRole') ]
61 };
62  
63 1 resource HostKeys => 'AWS::IAM::AccessKey', {
64 UserName => Ref('CfnUser')
65 };
66  
67 1 resource CreateAMISG => 'AWS::EC2::SecurityGroup', {
68 GroupDescription => "Security Group for Creating an AMI",
69 SecurityGroupIngress => [ SGRule(22, '0.0.0.0/0') ],
70 VpcId => Ref('VPC')
71 };
72  
73 1 resource EIP => 'AWS::EC2::EIP', {
74 Domain => 'vpc',
75 InstanceId => Ref('Instance'),
76 };
77  
78  
79 1 ▶ sub BUILD {
Subroutine BUILD: called CC=5 SCAR=16.8
Pod undocumented
80 1 my $self = shift;
81 1 my $udata;
82 1 ▶ if (not defined $self->params->template) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->params->template) { } 0 1 1
83 0 warn "You haven't passed templates to this deployment. Please make sure that you signal stack completion with cfn-signal -e 0 -r \"cfn-int setup complete\" '#-#WaitHandle#-#' if you're not in --devel mode";
84 } else {
85 1 $udata = CCfnX::CreateAMIUserData->new(files => $self->params->template, signal => (! $self->params->devel), os_family => $self->params->os_family);
86 }
87  
88 1 my $kp = $self->params->keypair;
89 1 ▶ $self->addResource(
Branch: 2 branches
BranchTrueFalseTotal
$kp ? : 0 1 1
$udata ? : 1 0 1
90 "Instance", 'AWS::EC2::Instance',
91 Tags => [ Tag('Name', Parameter('name')) ],
92 ImageId => $self->params->ami,
93 InstanceType => $self->params->instance_type,
94 SecurityGroupIds => [ Ref('CreateAMISG') ],
95 IamInstanceProfile => Ref('CfnInstanceProfile'),
96 SubnetId => Ref('AZ1'),
97 ($kp) ? (KeyName => $kp) : (),
98 ($udata) ? (UserData => $udata) : (),
99 );
100  
101 1 $self->addOutput(
102 InstanceID => Ref('Instance'),
103 );
104 1 $self->addOutput(
105 InstanceAddress => Ref('EIP')
106 );
107  
108 1 ▶ if (not $self->params->devel){
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->params->devel) 1 0 1
109 1 $self->addResource(
110 "WaitCondition", 'AWS::CloudFormation::WaitCondition',
111 Handle => Ref('WaitHandle'),
112 Timeout => "14400"
113 );
114 1 $self->addResource(
115 "WaitHandle", 'AWS::CloudFormation::WaitConditionHandle'
116 );
117 }
118 }
119 }
120  
121 1 1;
« CloudDeploy/CommandLine/Template.pm ↑ Summary CCfnX/ConsoleDeployer.pm »