| 1 | package App::FargateStack::Constants; | ||||||||||
| 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 App::FargateStack::Builder::Utils qw(choose); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use English qw(no_match_vars); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use JSON; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use parent qw(Exporter); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use Readonly; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | #################################################################### | ||||||||||
| 16 | # Boolean constants | ||||||||||
| 17 | #################################################################### | ||||||||||
| 18 | 1 | Readonly::Scalar our $TRUE => 1; | |||||||||
| 19 | 1 | Readonly::Scalar our $FALSE => 0; | |||||||||
| 20 | |||||||||||
| 21 | #################################################################### | ||||||||||
| 22 | # Character constants | ||||||||||
| 23 | #################################################################### | ||||||||||
| 24 | 1 | Readonly::Scalar our $EMPTY => q{}; | |||||||||
| 25 | 1 | Readonly::Scalar our $SPACE => q{ }; | |||||||||
| 26 | 1 | Readonly::Scalar our $DASH => q{-}; | |||||||||
| 27 | |||||||||||
| 28 | #################################################################### | ||||||||||
| 29 | # Task definition defaults & constants | ||||||||||
| 30 | #################################################################### | ||||||||||
| 31 | 1 | Readonly::Scalar our $DEFAULT_CPU_SIZE => 256; | |||||||||
| 32 | 1 | Readonly::Scalar our $DEFAULT_MEMORY_SIZE => 512; | |||||||||
| 33 | 1 | Readonly::Scalar our $DEFAULT_PORT => 80; | |||||||||
| 34 | 1 | Readonly::Scalar our $DEFAULT_EFS_PORT => 2049; | |||||||||
| 35 | 1 | Readonly::Scalar our $DEFAULT_RULE_ID => '1'; | |||||||||
| 36 | 1 | Readonly::Scalar our $IAM_POLICY_VERSION => '2012-10-17'; | |||||||||
| 37 | |||||||||||
| 38 | 1 | Readonly::Hash our %AWS_SERVICE_DOMAINS => ( | |||||||||
| 39 | events => 'events.amazonaws.com', | ||||||||||
| 40 | ecs => 'ecs-tasks.amazonaws.com', | ||||||||||
| 41 | task => 'ecs-tasks.amazonaws.com' | ||||||||||
| 42 | ); | ||||||||||
| 43 | |||||||||||
| 44 | 1 | Readonly::Hash our %ECS_TASK_PROFILES => ( | |||||||||
| 45 | tiny => { cpu => 256, memory => 512 }, | ||||||||||
| 46 | small => { cpu => 512, memory => 1024 }, | ||||||||||
| 47 | medium => { cpu => 1024, memory => 2048 }, | ||||||||||
| 48 | large => { cpu => 2048, memory => 4096 }, | ||||||||||
| 49 | xlarge => { cpu => 4096, memory => 8192 }, | ||||||||||
| 50 | '2xlarge' => { cpu => 8192, memory => 16_384 }, | ||||||||||
| 51 | ); | ||||||||||
| 52 | |||||||||||
| 53 | 1 | Readonly::Hash our %ECS_TASK_PROFILE_TYPES => ( | |||||||||
| 54 | web => 'medium', | ||||||||||
| 55 | job => 'medium', | ||||||||||
| 56 | daemon => 'medium', | ||||||||||
| 57 | task => 'tiny', | ||||||||||
| 58 | ); | ||||||||||
| 59 | |||||||||||
| 60 | ######################################################################## | ||||||||||
| 61 | # Poll timeouts | ||||||||||
| 62 | ######################################################################## | ||||||||||
| 63 | 1 | Readonly::Scalar our $DEFAULT_ECS_POLL_TIME => 5; | |||||||||
| 64 | 1 | Readonly::Scalar our $DEFAULT_ECS_POLL_LIMIT => 5 * 60 * 60; # 5m | |||||||||
| 65 | 1 | Readonly::Scalar our $ACM_REQUEST_SLEEP_TIME => 5; | |||||||||
| 66 | 1 | Readonly::Scalar our $DEFAULT_ALB_MAX_TRIES => 120; | |||||||||
| 67 | 1 | Readonly::Scalar our $DEFAULT_ALB_POLL_SLEEP_TIME => 5; | |||||||||
| 68 | |||||||||||
| 69 | ######################################################################## | ||||||||||
| 70 | # CloudTrail defaults & constants | ||||||||||
| 71 | ######################################################################## | ||||||||||
| 72 | 1 | Readonly::Scalar our $DEFAULT_MAX_EVENTS => 5; | |||||||||
| 73 | |||||||||||
| 74 | ######################################################################## | ||||||||||
| 75 | # Autoscaling defaults & constants | ||||||||||
| 76 | ######################################################################## | ||||||||||
| 77 | 1 | Readonly::Scalar our $DEFAULT_CPU_SCALING_LEVEL => 60; | |||||||||
| 78 | 1 | Readonly::Scalar our $DEFAULT_REQUESTS_SCALING_LEVEL => 500; | |||||||||
| 79 | 1 | Readonly::Scalar our $DEFAULT_AUTOSCALING_MIN_CAPACITY => 1; | |||||||||
| 80 | 1 | Readonly::Scalar our $DEFAULT_AUTOSCALING_MAX_CAPACITY => 2; | |||||||||
| 81 | 1 | Readonly::Scalar our $DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN => 60; | |||||||||
| 82 | 1 | Readonly::Scalar our $DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN => 300; | |||||||||
| 83 | |||||||||||
| 84 | ######################################################################## | ||||||||||
| 85 | # WAF defaults & constants | ||||||||||
| 86 | ######################################################################## | ||||||||||
| 87 | 1 | Readonly::Scalar our $WAF_AVAILABILITY_TIMEOUT => 5 * 60; | |||||||||
| 88 | 1 | Readonly::Scalar our $WAF_AVAILABILITY_SLEEP_TIME => 5; | |||||||||
| 89 | |||||||||||
| 90 | 1 | Readonly::Hash our %WAF_MANAGED_RULES => ( | |||||||||
| 91 | premium => [ | ||||||||||
| 92 | qw( | ||||||||||
| 93 | AWSManagedRulesACFPRuleSet | ||||||||||
| 94 | AWSManagedRulesATPRuleSet | ||||||||||
| 95 | AWSManagedRulesBotControlRuleSet | ||||||||||
| 96 | ) | ||||||||||
| 97 | ], | ||||||||||
| 98 | base => [ | ||||||||||
| 99 | qw( | ||||||||||
| 100 | AWSManagedRulesCommonRuleSet | ||||||||||
| 101 | AWSManagedRulesAmazonIpReputationList | ||||||||||
| 102 | AWSManagedRulesKnownBadInputsRuleSet | ||||||||||
| 103 | ) | ||||||||||
| 104 | ], | ||||||||||
| 105 | admin => [ | ||||||||||
| 106 | qw( | ||||||||||
| 107 | AWSManagedRulesAdminProtectionRuleSet | ||||||||||
| 108 | ) | ||||||||||
| 109 | ], | ||||||||||
| 110 | linux => [ | ||||||||||
| 111 | qw( | ||||||||||
| 112 | AWSManagedRulesLinuxRuleSet | ||||||||||
| 113 | AWSManagedRulesUnixRuleSet | ||||||||||
| 114 | ) | ||||||||||
| 115 | ], | ||||||||||
| 116 | wordpress => [ | ||||||||||
| 117 | qw( | ||||||||||
| 118 | AWSManagedRulesWordPressRuleSet | ||||||||||
| 119 | ) | ||||||||||
| 120 | ], | ||||||||||
| 121 | windows => [ | ||||||||||
| 122 | qw( | ||||||||||
| 123 | AWSManagedRulesWindowsRuleSet | ||||||||||
| 124 | ) | ||||||||||
| 125 | ], | ||||||||||
| 126 | php => [ | ||||||||||
| 127 | qw( | ||||||||||
| 128 | AWSManagedRulesPHPRuleSet | ||||||||||
| 129 | ) | ||||||||||
| 130 | ], | ||||||||||
| 131 | sql => [ | ||||||||||
| 132 | qw( | ||||||||||
| 133 | AWSManagedRulesSQLiRuleSet | ||||||||||
| 134 | ) | ||||||||||
| 135 | ], | ||||||||||
| 136 | anonymous => [ | ||||||||||
| 137 | qw( | ||||||||||
| 138 | AWSManagedRulesAnonymousIpList | ||||||||||
| 139 | ) | ||||||||||
| 140 | ], | ||||||||||
| 141 | ddos => [ | ||||||||||
| 142 | qw( | ||||||||||
| 143 | AWSManagedRulesAntiDDoSRuleSet | ||||||||||
| 144 | ) | ||||||||||
| 145 | ], | ||||||||||
| 146 | ); | ||||||||||
| 147 | |||||||||||
| 148 | 1 | Readonly::Hash our %WAF_MANAGED_RULE_BUNDLES => ( | |||||||||
| 149 | all => [qw(base linux wordpress php windows sql admin)], | ||||||||||
| 150 | default => [qw(base sql)], | ||||||||||
| 151 | 'linux-app' => [qw(base sql linux)], | ||||||||||
| 152 | 'wordpress-app' => [qw(base sql wordpress linux)], | ||||||||||
| 153 | 'windows-app' => [qw(base sql windows)], | ||||||||||
| 154 | ); | ||||||||||
| 155 | |||||||||||
| 156 | 1 | Readonly::Scalar our $WAF_RULE_STUB => <<'END_OF_STUB'; | |||||||||
| 157 | { | ||||||||||
| 158 | "Name": "", | ||||||||||
| 159 | "Priority": 0, | ||||||||||
| 160 | "Statement":{ | ||||||||||
| 161 | "ManagedRuleGroupStatement": { | ||||||||||
| 162 | "VendorName": "AWS", | ||||||||||
| 163 | "Name": "" | ||||||||||
| 164 | } | ||||||||||
| 165 | }, | ||||||||||
| 166 | "OverrideAction": { "None": {} }, | ||||||||||
| 167 | "VisibilityConfig": { | ||||||||||
| 168 | "SampledRequestsEnabled": true, | ||||||||||
| 169 | "CloudWatchMetricsEnabled": true, | ||||||||||
| 170 | "MetricName": "" | ||||||||||
| 171 | } | ||||||||||
| 172 | } | ||||||||||
| 173 | END_OF_STUB | ||||||||||
| 174 | |||||||||||
| 175 | #################################################################### | ||||||||||
| 176 | # ARN templates | ||||||||||
| 177 | #################################################################### | ||||||||||
| 178 | 1 | Readonly::Scalar our $EFS_ARN_TEMPLATE => 'arn:aws:elasticfilesystem:%s:%s:file-system/%s'; | |||||||||
| 179 | 1 | Readonly::Scalar our $TASK_DEFINITION_ARN_TEMPLATE => 'arn:aws:ecs:%s:%s:task-definition/%s:*'; | |||||||||
| 180 | 1 | Readonly::Scalar our $CLUSTER_ARN_TEMPLATE => 'arn:aws:ecs:%s:%s:cluster/%s'; | |||||||||
| 181 | 1 | Readonly::Scalar our $ROLE_ARN_TEMPLATE => 'arn:aws:iam::%s:role/%s'; | |||||||||
| 182 | 1 | Readonly::Scalar our $QUEUE_ARN_TEMPLATE => 'arn:aws:sqs:%s:%s:%s'; | |||||||||
| 183 | 1 | Readonly::Scalar our $S3_BUCKET_ARN_TEMPLATE => 'arn:aws:s3:::%s'; | |||||||||
| 184 | 1 | Readonly::Scalar our $ECR_ARN_TEMPLATE => 'arn:aws:ecr:%s:%s:repository/%s'; | |||||||||
| 185 | |||||||||||
| 186 | ######################################################################## | ||||||||||
| 187 | # Health check defaults & constants | ||||||||||
| 188 | ######################################################################## | ||||||||||
| 189 | 1 | Readonly::Scalar our $DEFAULT_HEALTH_CHECK_INTERVAL => 30; | |||||||||
| 190 | 1 | Readonly::Scalar our $DEFAULT_HEALTH_CHECK_TIMEOUT => 5; | |||||||||
| 191 | 1 | Readonly::Scalar our $DEFAULT_HEALTH_HEALTHY_CHECK_THRESHOLD => 5; | |||||||||
| 192 | 1 | Readonly::Scalar our $DEFAULT_HEALTH_UNHEALTHY_CHECK_THRESHOLD => 2; | |||||||||
| 193 | |||||||||||
| 194 | ######################################################################## | ||||||||||
| 195 | # SQS defaults & constants | ||||||||||
| 196 | ######################################################################## | ||||||||||
| 197 | 1 | Readonly::Scalar our $DEFAULT_SQS_VISIBILITY_TIMEOUT => 30; | |||||||||
| 198 | 1 | Readonly::Scalar our $DEFAULT_SQS_MESSAGE_RETENTION_PERIOD => 345_600; | |||||||||
| 199 | 1 | Readonly::Scalar our $DEFAULT_SQS_RECEIVE_MESSAGE_WAIT_TIME_SECONDS => 0; | |||||||||
| 200 | 1 | Readonly::Scalar our $DEFAULT_SQS_DELAY_SECONDS => 0; | |||||||||
| 201 | 1 | Readonly::Scalar our $DEFAULT_SQS_MAX_RECEIVE_COUNT => 5; | |||||||||
| 202 | 1 | Readonly::Scalar our $DEFAULT_SQS_MAXIMUM_MESSAGE_SIZE => 262_144; | |||||||||
| 203 | |||||||||||
| 204 | 1 | require App::FargateStack::Builder::Utils; | |||||||||
| 205 | |||||||||||
| 206 | 1 | Readonly::Scalar our $QUEUE_ATTRIBUTES => App::FargateStack::Builder::Utils::ToCamelCase( | |||||||||
| 207 | [ qw( | ||||||||||
| 208 | delay_seconds | ||||||||||
| 209 | last_modified_timestamp | ||||||||||
| 210 | max_receive_count | ||||||||||
| 211 | maximum_message_size | ||||||||||
| 212 | message_retention_period | ||||||||||
| 213 | receive_message_wait_time_seconds | ||||||||||
| 214 | redrive_policy | ||||||||||
| 215 | visibility_timeout | ||||||||||
| 216 | ) | ||||||||||
| 217 | ], | ||||||||||
| 218 | ); | ||||||||||
| 219 | |||||||||||
| 220 | ######################################################################## | ||||||||||
| 221 | # CloudWatch Logs defaults & constants | ||||||||||
| 222 | ######################################################################## | ||||||||||
| 223 | 1 | Readonly::Scalar our $CLOUDWATCH_LOGS_RETENTION_DAYS => | |||||||||
| 224 | [ 1, 3, 5, 7, 14, 30, 60, 90, 120, 150, 180, 365, 400, 545, 731, 1096, 1827, 2192, 2557, 2922, 3288, 3653, ]; | ||||||||||
| 225 | 1 | Readonly::Scalar our $DEFAULT_LOG_RETENTION_DAYS => 14; | |||||||||
| 226 | 1 | Readonly::Scalar our $DEFAULT_LOG_POLL_TIME => 5; | |||||||||
| 227 | |||||||||||
| 228 | ######################################################################## | ||||||||||
| 229 | # Time defaults & constants | ||||||||||
| 230 | ######################################################################## | ||||||||||
| 231 | 1 | Readonly::Scalar our $SEC_PER_MIN => 60; | |||||||||
| 232 | 1 | Readonly::Scalar our $SEC_PER_HOUR => 60 * $SEC_PER_MIN; | |||||||||
| 233 | 1 | Readonly::Scalar our $SEC_PER_DAY => 24 * $SEC_PER_HOUR; | |||||||||
| 234 | |||||||||||
| 235 | ######################################################################## | ||||||||||
| 236 | # Default name functions | ||||||||||
| 237 | # (see App::FargateStack::Builder::Utils::create_default) | ||||||||||
| 238 | ######################################################################## | ||||||||||
| 239 | Readonly::Hash our %DEFAULT_NAMES => ( | ||||||||||
| 240 | 0 | ▶ | 'autoscaling-policy-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 241 | 0 | my ( $self, $task_name ) = @_; | |||||||||
| 242 | |||||||||||
| 243 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 244 | |||||||||||
| 245 | 0 | return sprintf 'app-fargatestack-%s-%s-autoscaling-policy', $app_name, $task_name; | |||||||||
| 246 | }, | ||||||||||
| 247 | 0 | ▶ | 'security-group' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 248 | 0 | my ( $self, @args ) = @_; | |||||||||
| 249 | |||||||||||
| 250 | 0 | return sprintf '%s-sg', $self->get_config->{app}->{name}; | |||||||||
| 251 | }, | ||||||||||
| 252 | 0 | ▶ | 'log-group' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 253 | 0 | my ( $self, @args ) = @_; | |||||||||
| 254 | |||||||||||
| 255 | 0 | return sprintf '/ecs/app-fargatestack/%s', $self->get_config->{app}->{name}; | |||||||||
| 256 | }, | ||||||||||
| 257 | 0 | ▶ | 'role-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 258 | 0 | my ( $self, $type ) = @_; | |||||||||
| 259 | |||||||||||
| 260 | 0 | my $app_name = $self->normalize_name( $self->get_config->{app}->{name} ); | |||||||||
| 261 | |||||||||||
| 262 | 0 | ▶ | my @args = choose { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 263 | 0 | ▶ | return ( 'Events', $app_name, $EMPTY ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 264 | if $type eq 'events'; | ||||||||||
| 265 | |||||||||||
| 266 | 0 | ▶ | return ( 'Fargate', $app_name, $EMPTY ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 267 | if $type eq 'ecs'; | ||||||||||
| 268 | |||||||||||
| 269 | 0 | ▶ | return ( 'Fargate', $app_name, 'Task' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 270 | if $type eq 'task'; | ||||||||||
| 271 | 0 | }; | |||||||||
| 272 | |||||||||||
| 273 | # Ex: FargateSqsExampleTaskRole' | ||||||||||
| 274 | 0 | return sprintf '%s%s%sRole', @args; | |||||||||
| 275 | }, | ||||||||||
| 276 | 0 | ▶ | 'policy-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 277 | 0 | my ( $self, $type ) = @_; | |||||||||
| 278 | |||||||||||
| 279 | 0 | my $app_name = $self->normalize_name( $self->get_config->{app}->{name} ); | |||||||||
| 280 | |||||||||||
| 281 | 0 | ▶ | my @args = choose { | ||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||
| 282 | 0 | ▶ | return ( 'Events', $app_name, $EMPTY ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 283 | if $type eq 'events'; | ||||||||||
| 284 | |||||||||||
| 285 | 0 | ▶ | return ( 'Fargate', $app_name, $EMPTY ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 286 | if $type eq 'ecs'; | ||||||||||
| 287 | |||||||||||
| 288 | 0 | ▶ | return ( 'Fargate', $app_name, 'Task' ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 289 | if $type eq 'task'; | ||||||||||
| 290 | 0 | }; | |||||||||
| 291 | |||||||||||
| 292 | # Ex: FargateSqsExampleTaskPolicy' | ||||||||||
| 293 | 0 | return sprintf '%s%s%sPolicy', @args; | |||||||||
| 294 | }, | ||||||||||
| 295 | 0 | ▶ | 'rule-id' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 296 | 0 | my ( $self, $task_name ) = @_; | |||||||||
| 297 | |||||||||||
| 298 | 0 | return sprintf '%s-target', $task_name; | |||||||||
| 299 | }, | ||||||||||
| 300 | 0 | ▶ | 'rule-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 301 | 0 | my ( $self, $task_name ) = @_; | |||||||||
| 302 | |||||||||||
| 303 | 0 | return sprintf '%s-schedule', $task_name; | |||||||||
| 304 | }, | ||||||||||
| 305 | 0 | ▶ | 'target-group-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 306 | 0 | my ($self) = @_; | |||||||||
| 307 | |||||||||||
| 308 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 309 | 0 | return sprintf '%s-tg', $app_name; | |||||||||
| 310 | }, | ||||||||||
| 311 | 0 | ▶ | 'cluster-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 312 | 0 | my ($self) = @_; | |||||||||
| 313 | |||||||||||
| 314 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 315 | |||||||||||
| 316 | 0 | return sprintf '%s-cluster', $app_name; | |||||||||
| 317 | }, | ||||||||||
| 318 | 0 | ▶ | 'alb-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 319 | 0 | my ($self) = @_; | |||||||||
| 320 | |||||||||||
| 321 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 322 | |||||||||||
| 323 | 0 | return sprintf '%s-alb', $app_name; | |||||||||
| 324 | }, | ||||||||||
| 325 | 0 | ▶ | 'alb-security-group-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 326 | 0 | my ($self) = @_; | |||||||||
| 327 | |||||||||||
| 328 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 329 | |||||||||||
| 330 | 0 | return sprintf '%s-alb-sg', $app_name; | |||||||||
| 331 | }, | ||||||||||
| 332 | 0 | ▶ | 'scheduled-action-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 333 | 0 | my ( $self, $action_name ) = @_; | |||||||||
| 334 | |||||||||||
| 335 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 336 | |||||||||||
| 337 | 0 | return sprintf '%s-%s-schedule', $app_name, $action_name; | |||||||||
| 338 | }, | ||||||||||
| 339 | |||||||||||
| 340 | 0 | ▶ | 'web-acl-name' => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 341 | 0 | my ($self) = @_; | |||||||||
| 342 | |||||||||||
| 343 | 0 | my $app_name = $self->get_config->{app}->{name}; | |||||||||
| 344 | 0 | return sprintf '%s-acl', $app_name; | |||||||||
| 345 | }, | ||||||||||
| 346 | 1 | ); | |||||||||
| 347 | |||||||||||
| 348 | ######################################################################## | ||||||||||
| 349 | # EventBridge defaults & constants | ||||||||||
| 350 | ######################################################################## | ||||||||||
| 351 | 1 | Readonly::Scalar our $EVENT_SCHEDULER_TYPE_URL => 'https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html'; | |||||||||
| 352 | |||||||||||
| 353 | ######################################################################## | ||||||||||
| 354 | # Help subjects | ||||||||||
| 355 | ######################################################################## | ||||||||||
| 356 | 1 | Readonly::Hash our %HELP_SUBJECTS => ( | |||||||||
| 357 | 'tbd' => [ | ||||||||||
| 358 | 'TBD' => <<'END_OF_TEXT' | ||||||||||
| 359 | Our current TODO list. Add your request at | ||||||||||
| 360 | https://github.com/rlauer6/App-Fargate | ||||||||||
| 361 | END_OF_TEXT | ||||||||||
| 362 | ], | ||||||||||
| 363 | 'overview' => [ | ||||||||||
| 364 | 'OVERVIEW' => <<'END_OF_TEXT' | ||||||||||
| 365 | An overview of the App::FargateStack framework. | ||||||||||
| 366 | END_OF_TEXT | ||||||||||
| 367 | ], | ||||||||||
| 368 | 'cloudwatch logs' => [ | ||||||||||
| 369 | 'CLOUDWATCH LOGS' => <<'END_OF_TEXT' | ||||||||||
| 370 | Information on Cloudwatch log groups and how to view logs from your tasks. | ||||||||||
| 371 | END_OF_TEXT | ||||||||||
| 372 | ], | ||||||||||
| 373 | 'command list' => [ | ||||||||||
| 374 | 'COMMAND LIST' => <<'END_OF_TEXT' | ||||||||||
| 375 | A detailed description of available commands. | ||||||||||
| 376 | END_OF_TEXT | ||||||||||
| 377 | ], | ||||||||||
| 378 | 'daemon services' => [ | ||||||||||
| 379 | 'DAEMON SERVICES' => <<'END_OF_TEXT' | ||||||||||
| 380 | Information on how to create long running daemon services using this | ||||||||||
| 381 | framework. | ||||||||||
| 382 | END_OF_TEXT | ||||||||||
| 383 | ], | ||||||||||
| 384 | 'scheduled jobs' => [ | ||||||||||
| 385 | 'SCHEDULED JOBS' => <<'END_OF_TEXT' | ||||||||||
| 386 | A description of using the framework to create scheduled and one-shot workloads. | ||||||||||
| 387 | END_OF_TEXT | ||||||||||
| 388 | ], | ||||||||||
| 389 | 'task size' => [ | ||||||||||
| 390 | 'TASK SIZE' => <<'END_OF_TEXT' | ||||||||||
| 391 | Using the "size:" key to set the task's memory and cpu parameters. | ||||||||||
| 392 | END_OF_TEXT | ||||||||||
| 393 | ], | ||||||||||
| 394 | 'http services' => [ | ||||||||||
| 395 | 'HTTP SERVICES' => <<'END_OF_TEXT' | ||||||||||
| 396 | A description of how the framework can provision a fully functional | ||||||||||
| 397 | web application using Fargate. | ||||||||||
| 398 | END_OF_TEXT | ||||||||||
| 399 | ], | ||||||||||
| 400 | |||||||||||
| 401 | 'log groups' => [ | ||||||||||
| 402 | 'CLOUDWATCH LOG GROUPS' => <<'END_OF_TEXT' | ||||||||||
| 403 | Information on how log groups are provisioned and configure. | ||||||||||
| 404 | END_OF_TEXT | ||||||||||
| 405 | ], | ||||||||||
| 406 | 'iam permissions' => [ | ||||||||||
| 407 | 'IAM PERMISSIONS' => <<'END_OF_TEXT' | ||||||||||
| 408 | A discussion of how the framework creates IAM roles and policies for | ||||||||||
| 409 | the resources used in your tasks. | ||||||||||
| 410 | END_OF_TEXT | ||||||||||
| 411 | ], | ||||||||||
| 412 | 'environment variables' => [ | ||||||||||
| 413 | 'ENVIRONMENT VARIABLES' => <<'END_OF_TEXT' | ||||||||||
| 414 | How to injecting environment variables into your container. Also | ||||||||||
| 415 | include information on using secrets fromSecretsManager in your | ||||||||||
| 416 | environment. | ||||||||||
| 417 | END_OF_TEXT | ||||||||||
| 418 | ], | ||||||||||
| 419 | 'queues' => [ | ||||||||||
| 420 | 'SQS QUEUES' => <<'END_OF_TEXT' | ||||||||||
| 421 | How to create and configure SQS queues for your application. | ||||||||||
| 422 | END_OF_TEXT | ||||||||||
| 423 | ], | ||||||||||
| 424 | 'efs support' => [ | ||||||||||
| 425 | 'FILESYSTEM SUPPORT' => <<'END_OF_TEXT' | ||||||||||
| 426 | Configuring support for EFS files systems inside your container. | ||||||||||
| 427 | END_OF_TEXT | ||||||||||
| 428 | ], | ||||||||||
| 429 | 'filesystem support' => 'efs support', | ||||||||||
| 430 | 'buckets' => [ | ||||||||||
| 431 | 'S3 BUCKETS' => <<'END_OF_TEXT' | ||||||||||
| 432 | Creating and configuring S3 buckets. | ||||||||||
| 433 | END_OF_TEXT | ||||||||||
| 434 | ], | ||||||||||
| 435 | 'networking' => [ | ||||||||||
| 436 | 'NETWORKING' => <<'END_OF_TEXT' | ||||||||||
| 437 | Explanation of how the framework recognizes and uses your networking | ||||||||||
| 438 | resources. | ||||||||||
| 439 | END_OF_TEXT | ||||||||||
| 440 | ], | ||||||||||
| 441 | 'roadmap' => [ | ||||||||||
| 442 | 'ROADMAP' => <<'END_OF_TEXT' | ||||||||||
| 443 | A peek at what's next for App::FargateStack. | ||||||||||
| 444 | END_OF_TEXT | ||||||||||
| 445 | ], | ||||||||||
| 446 | 'cli option defaults' => [ | ||||||||||
| 447 | 'CLI OPTION DEFAULTS' => <<'END_OF_TEXT' | ||||||||||
| 448 | Save keystrokes with App::Fargate's automatic option saving feature. | ||||||||||
| 449 | END_OF_TEXT | ||||||||||
| 450 | ], | ||||||||||
| 451 | 'configuration file' => [ | ||||||||||
| 452 | 'CONFIGURATION' => <<'END_OF_TEXT' | ||||||||||
| 453 | Detailed explanation of the App::Fargate configuration file. | ||||||||||
| 454 | END_OF_TEXT | ||||||||||
| 455 | ], | ||||||||||
| 456 | 'limitations' => [ | ||||||||||
| 457 | 'LIMITATIONS' => <<'END_OF_TEXT' | ||||||||||
| 458 | END_OF_TEXT | ||||||||||
| 459 | ], | ||||||||||
| 460 | 'troubleshooting' => [ | ||||||||||
| 461 | 'TROUBLESHOOTING' => <<'END_OF_TEXT' | ||||||||||
| 462 | Hints and tips for troubleshooting. | ||||||||||
| 463 | END_OF_TEXT | ||||||||||
| 464 | ], | ||||||||||
| 465 | 'security groups' => [ | ||||||||||
| 466 | 'SECURITY GROUPS' => <<'END_OF_TEXT' | ||||||||||
| 467 | How the framework provisions and configures security groups. | ||||||||||
| 468 | END_OF_TEXT | ||||||||||
| 469 | ], | ||||||||||
| 470 | ); | ||||||||||
| 471 | |||||||||||
| 472 | 1 | Readonly::Scalar our $LOG4PERL_CONF => <<'END_OF_CONF'; | |||||||||
| 473 | log4perl.logger = INFO, Screen | ||||||||||
| 474 | log4perl.appender.Screen = Log::Log4perl::Appender::ScreenColoredLevels | ||||||||||
| 475 | log4perl.appender.Screen.stderr = 1 | ||||||||||
| 476 | log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout | ||||||||||
| 477 | log4perl.appender.Screen.layout.ConversionPattern = [%d] %m%n | ||||||||||
| 478 | log4perl.appender.Screen.color.DEBUG=magenta | ||||||||||
| 479 | log4perl.appender.Screen.color.INFO=green | ||||||||||
| 480 | log4perl.appender.Screen.color.WARN=yellow | ||||||||||
| 481 | log4perl.appender.Screen.color.ERROR=red | ||||||||||
| 482 | log4perl.appender.Screen.color.FATAL=bold red | ||||||||||
| 483 | log4perl.appender.Screen.color.TRACE=bold white | ||||||||||
| 484 | END_OF_CONF | ||||||||||
| 485 | |||||||||||
| 486 | 1 | our @EXPORT = ( | |||||||||
| 487 | ###################################################################### | ||||||||||
| 488 | # chars | ||||||||||
| 489 | ###################################################################### | ||||||||||
| 490 | qw( | ||||||||||
| 491 | $EMPTY | ||||||||||
| 492 | $DASH | ||||||||||
| 493 | $SPACE | ||||||||||
| 494 | ), | ||||||||||
| 495 | ###################################################################### | ||||||||||
| 496 | # booleans | ||||||||||
| 497 | ###################################################################### | ||||||||||
| 498 | qw( | ||||||||||
| 499 | $FALSE | ||||||||||
| 500 | $TRUE | ||||||||||
| 501 | ), | ||||||||||
| 502 | ###################################################################### | ||||||||||
| 503 | # CloudTrail | ||||||||||
| 504 | ###################################################################### | ||||||||||
| 505 | qw( | ||||||||||
| 506 | $DEFAULT_MAX_EVENTS | ||||||||||
| 507 | ), | ||||||||||
| 508 | ###################################################################### | ||||||||||
| 509 | # EFS | ||||||||||
| 510 | ###################################################################### | ||||||||||
| 511 | qw( | ||||||||||
| 512 | $DEFAULT_EFS_PORT | ||||||||||
| 513 | ), | ||||||||||
| 514 | ###################################################################### | ||||||||||
| 515 | # EventBridge | ||||||||||
| 516 | ###################################################################### | ||||||||||
| 517 | qw( | ||||||||||
| 518 | $DEFAULT_RULE_ID | ||||||||||
| 519 | $EVENT_SCHEDULER_TYPE_URL | ||||||||||
| 520 | ), | ||||||||||
| 521 | ###################################################################### | ||||||||||
| 522 | # Miscellaneous | ||||||||||
| 523 | ###################################################################### | ||||||||||
| 524 | qw( | ||||||||||
| 525 | %DEFAULT_NAMES | ||||||||||
| 526 | ), | ||||||||||
| 527 | ###################################################################### | ||||||||||
| 528 | # Log4perl | ||||||||||
| 529 | ###################################################################### | ||||||||||
| 530 | qw( | ||||||||||
| 531 | $LOG4PERL_CONF | ||||||||||
| 532 | ), | ||||||||||
| 533 | ###################################################################### | ||||||||||
| 534 | # Help | ||||||||||
| 535 | ###################################################################### | ||||||||||
| 536 | qw( | ||||||||||
| 537 | %HELP_SUBJECTS | ||||||||||
| 538 | ), | ||||||||||
| 539 | ###################################################################### | ||||||||||
| 540 | # Poll timeouts | ||||||||||
| 541 | ###################################################################### | ||||||||||
| 542 | qw( | ||||||||||
| 543 | $ACM_REQUEST_SLEEP_TIME | ||||||||||
| 544 | $DEFAULT_ALB_MAX_TRIES | ||||||||||
| 545 | $DEFAULT_ALB_POLL_SLEEP_TIME | ||||||||||
| 546 | $DEFAULT_ECS_POLL_LIMIT | ||||||||||
| 547 | $DEFAULT_ECS_POLL_TIME | ||||||||||
| 548 | ), | ||||||||||
| 549 | ###################################################################### | ||||||||||
| 550 | # Task definition defaults | ||||||||||
| 551 | ###################################################################### | ||||||||||
| 552 | qw( | ||||||||||
| 553 | $DEFAULT_CPU_SIZE | ||||||||||
| 554 | $DEFAULT_MEMORY_SIZE | ||||||||||
| 555 | $DEFAULT_PORT | ||||||||||
| 556 | $IAM_POLICY_VERSION | ||||||||||
| 557 | %AWS_SERVICE_DOMAINS | ||||||||||
| 558 | %ECS_TASK_PROFILES | ||||||||||
| 559 | %ECS_TASK_PROFILE_TYPES | ||||||||||
| 560 | ), | ||||||||||
| 561 | ###################################################################### | ||||||||||
| 562 | # CloudWatch Logs | ||||||||||
| 563 | ###################################################################### | ||||||||||
| 564 | qw( | ||||||||||
| 565 | $CLOUDWATCH_LOGS_RETENTION_DAYS | ||||||||||
| 566 | $DEFAULT_LOG_POLL_TIME | ||||||||||
| 567 | $DEFAULT_LOG_RETENTION_DAYS | ||||||||||
| 568 | ), | ||||||||||
| 569 | ###################################################################### | ||||||||||
| 570 | # WAF | ||||||||||
| 571 | ###################################################################### | ||||||||||
| 572 | qw( | ||||||||||
| 573 | $WAF_AVAILABILITY_SLEEP_TIME | ||||||||||
| 574 | $WAF_AVAILABILITY_TIMEOUT | ||||||||||
| 575 | $WAF_RULE_STUB | ||||||||||
| 576 | %WAF_MANAGED_RULES | ||||||||||
| 577 | %WAF_MANAGED_RULE_BUNDLES | ||||||||||
| 578 | ), | ||||||||||
| 579 | ###################################################################### | ||||||||||
| 580 | # Health Checks | ||||||||||
| 581 | ###################################################################### | ||||||||||
| 582 | qw( | ||||||||||
| 583 | $DEFAULT_HEALTH_CHECK_INTERVAL | ||||||||||
| 584 | $DEFAULT_HEALTH_CHECK_TIMEOUT | ||||||||||
| 585 | $DEFAULT_HEALTH_HEALTHY_CHECK_THRESHOLD | ||||||||||
| 586 | $DEFAULT_HEALTH_UNHEALTHY_CHECK_THRESHOLD | ||||||||||
| 587 | ), | ||||||||||
| 588 | ###################################################################### | ||||||||||
| 589 | # SQS | ||||||||||
| 590 | ###################################################################### | ||||||||||
| 591 | qw( | ||||||||||
| 592 | $DEFAULT_SQS_DELAY_SECONDS | ||||||||||
| 593 | $DEFAULT_SQS_MAXIMUM_MESSAGE_SIZE | ||||||||||
| 594 | $DEFAULT_SQS_MAX_RECEIVE_COUNT | ||||||||||
| 595 | $DEFAULT_SQS_MESSAGE_RETENTION_PERIOD | ||||||||||
| 596 | $DEFAULT_SQS_RECEIVE_MESSAGE_WAIT_TIME_SECONDS | ||||||||||
| 597 | $DEFAULT_SQS_VISIBILITY_TIMEOUT | ||||||||||
| 598 | $QUEUE_ATTRIBUTES | ||||||||||
| 599 | ), | ||||||||||
| 600 | ###################################################################### | ||||||||||
| 601 | # Time defaults | ||||||||||
| 602 | ###################################################################### | ||||||||||
| 603 | qw( | ||||||||||
| 604 | $SEC_PER_DAY | ||||||||||
| 605 | $SEC_PER_HOUR | ||||||||||
| 606 | $SEC_PER_MIN | ||||||||||
| 607 | ), | ||||||||||
| 608 | ###################################################################### | ||||||||||
| 609 | # Autoscaling | ||||||||||
| 610 | ###################################################################### | ||||||||||
| 611 | qw( | ||||||||||
| 612 | $DEFAULT_AUTOSCALING_MAX_CAPACITY | ||||||||||
| 613 | $DEFAULT_AUTOSCALING_MIN_CAPACITY | ||||||||||
| 614 | $DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN | ||||||||||
| 615 | $DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN | ||||||||||
| 616 | $DEFAULT_CPU_SCALING_LEVEL | ||||||||||
| 617 | $DEFAULT_REQUESTS_SCALING_LEVEL | ||||||||||
| 618 | ), | ||||||||||
| 619 | ###################################################################### | ||||||||||
| 620 | # Templates | ||||||||||
| 621 | ###################################################################### | ||||||||||
| 622 | qw( | ||||||||||
| 623 | $CLUSTER_ARN_TEMPLATE | ||||||||||
| 624 | $ECR_ARN_TEMPLATE | ||||||||||
| 625 | $EFS_ARN_TEMPLATE | ||||||||||
| 626 | $QUEUE_ARN_TEMPLATE | ||||||||||
| 627 | $ROLE_ARN_TEMPLATE | ||||||||||
| 628 | $S3_BUCKET_ARN_TEMPLATE | ||||||||||
| 629 | $TASK_DEFINITION_ARN_TEMPLATE | ||||||||||
| 630 | ), | ||||||||||
| 631 | ); | ||||||||||
| 632 | |||||||||||
| 633 | 1 | 1; | |||||||||