| 1 | package App::FargateStack::Builder::EFS; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use App::FargateStack::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | sub add_volumes { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_volumes: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my ( $self, $task ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | return | ||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | if !$task->{efs}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | require App::EFS; | |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | my $efs = $self->fetch_efs(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | my $efs_config = $task->{efs}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my ( $id, $path, $mount_point ) = @{$efs_config}{qw(id path mount_point)}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | if ( !$mount_point ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | $self->log_error('task:efs WARNING: no mount point defined...using /mnt'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | my ( $arn, $readonly ) = @{$efs_config}{qw(arn readonly)}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | log_die( $self, 'ERROR: no id set for EFS volume' ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | if !$id; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # - validate id - | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( !$arn || !$self->get_cache ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$arn and $self->get_cache
MC/DC0%0/2
$arn and $self->get_cache
$arn
$self->get_cache
Truth table0%0/3
A and B
A= $arnB= $self->get_cache
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $self->log_info( 'task: validating EFS id: [%s]...', $id ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $file_system = $efs->describe_file_systems( $id, 'FileSystems' ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | log_die( $self, "ERROR: no such EFS file system (%s) found\n", $id ) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | if !$file_system; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $arn = $efs_config->{arn} = $file_system->[0]->{FileSystemArn}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->log_info( 'task: EFS ARN: [%s]', $arn ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | [ { name => 'efs-volume', | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/7
$path // "/"
$mount_point // "/mnt"
defined $readonly and $readonly
MC/DC0%0/1
$path // "/"
$path
MC/DC0%0/1
$mount_point // "/mnt"
$mount_point
MC/DC0%0/2
defined $readonly and $readonly
defined $readonly
$readonly
Truth table0%0/2
A
A= $path
Truth table0%0/2
A
A= $mount_point
Truth table0%0/3
A and B
A= defined $readonlyB= $readonly
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | efsVolumeConfiguration => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | fileSystemId => $id, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | rootDirectory => $path // q{/}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | transitEncryption => 'ENABLED' | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | [ { sourceVolume => 'efs-volume', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | containerPath => $mount_point // '/mnt', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | readOnly => defined $readonly && $readonly ? $JSON::true : $JSON::false, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub add_efs_policy { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_efs_policy: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $tasks = $self->get_config->{tasks}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my @efs_arns; | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | foreach my $task_name ( keys %{$tasks} ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $efs = $tasks->{$task_name}->{efs}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | next if !$efs || !$efs->{id}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$efs and $efs->{"id"}
MC/DC0%0/2
$efs and $efs->{"id"}
$efs
$efs->{"id"}
Truth table0%0/3
A and B
A= $efsB= $efs->{"id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | push @efs_arns, sprintf $EFS_ARN_TEMPLATE, $self->get_region, $self->get_account, $efs->{id}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | return | ||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if !@efs_arns; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | Effect => 'Allow', | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | Action => [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | qw( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | elasticfilesystem:ClientMount | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | elasticfilesystem:ClientWrite | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | elasticfilesystem:ClientRootAccess | ||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Resource => \@efs_arns, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||