App-FargateStack
view release on metacpan or search on metacpan
lib/App/FargateStack/Pod.pm view on Meta::CPAN
service's dynamic IP address. Additionally, using a load balancer
allows you to create custom routing rules to your service. If you want
to run multiple tasks for your service to support handling more
traffice a load balancer is required.
With those things in mind the framework automatically uses an ALB for
HTTP services and creates an alias record (A) for your domain for both
internal and external facing services.
=head2 AWS WAF Support
For external-facing HTTPS services, C<App::FargateStack> can automate
the creation and association of an AWS Web Application Firewall (WAF)
to provide an essential layer of security. This protects your
application from common web exploits and bots that could affect
availability or compromise security.
The framework follows a "Hybrid Management Model" for WAF, designed to
provide a secure, sensible baseline out-of-the-box while giving you
full control over fine-grained rule customization.
=head3 Enabling WAF Protection
To enable WAF, simply add a C<waf> block with C<enabled: true> to your
C<alb> configuration:
alb:
# ... existing alb configuration ...
waf:
enabled: true
=head3 Configuring Managed Rules
To simplify configuration, C<App::FargateStack> uses a keyword-based
system for enabling AWS Managed Rule Groups. You can specify a list of
keywords under the C<managed_rules> key in your C<waf> configuration.
If the C<managed_rules> key is omitted, the framework will apply the
C<default> bundle, which provides a strong and cost-effective security
baseline.
waf:
enabled: true
managed_rules: [linux-app, admin, -php]
The framework supports both individual rule sets and pre-configured
"bundles" for common application types. It also supports a subtractive
syntax (prefixing a keyword with a C<->) to remove rule sets from a
bundle.
=head4 Rule Set Keywords
=over 4
=item * B<base>: A strong baseline including C<AWSManagedRulesCommonRuleSet>, C<AWSManagedRulesAmazonIpReputationList>, and C<AWSManagedRulesKnownBadInputsRuleSet>.
=item * B<admin>: Protects exposed administrative pages (C<AWSManagedRulesAdminProtectionRuleSet>).
=item * B<sql>: Protects against SQL injection attacks (C<AWSManagedRulesSQLiRuleSet>).
=item * B<linux>: Includes rules for Linux and Unix-like environments.
=item * B<php>: Includes rules for applications running on PHP.
=item * B<wordpress>: Includes rules specific to WordPress sites.
=item * B<windows>: Includes rules for Windows Server environments.
=item * B<anonymous>: B<Use with caution.> Blocks traffic from anonymous sources like VPNs and proxies, which may block legitimate users.
=item * B<ddos>: Mitigates application-layer (Layer 7) DDoS attacks like HTTP floods.
=item * B<premium>: B<Warning: Extra Cost.> Enables advanced, paid protections for bot control and account takeover prevention.
=back
=head4 Rule Bundles
=over 4
=item * B<default>: Includes C<base> and C<sql>. This is the recommended starting point for most applications.
=item * B<linux-app>: Includes C<default> and C<linux>.
=item * B<wordpress-app>: Includes C<default>, C<linux>, and C<wordpress>.
=item * B<windows-app>: Includes C<default> and C<windows>.
=item * B<all>: Includes all standard, non-premium rule sets. B<Warning:> This will likely exceed the default WCU quota and may incur additional costs.
=back
=head3 The Bootstrap Process (First Run)
On the first C<apply> run with WAF enabled, the framework will perform
a one-time bootstrap:
=over 4
=item 1.
It generates a default F<web-acl.json> file in your project
directory. This file contains the complete definition of your Web ACL,
including the rules generated from your C<managed_rules> keywords.
=item 2.
It calls C<aws wafv2 create-web-acl> to create a new Web ACL.
=item 3.
It calls C<aws wafv2 associate-web-acl> to link the new Web ACL to
your Application Load Balancer.
=item 4.
It updates your configuration file with the state of the new
WAF resources, including its Name, ID, ARN, LockToken, and a checksum
of the F<web-acl.json> file.
=item 5.
( run in 2.558 seconds using v1.01-cache-2.11-cpan-64ef6c95b5d )