@@ -31,6 +31,8 @@ Parameters:
3131 AlbListenerRulePriorityPrefix : { Type: String }
3232 AlbAccessToken : { Type: AWS::SSM::Parameter::Value<String> }
3333 LoadBalancerSecurityGroupId : { Type: AWS::EC2::SecurityGroup::Id }
34+ SharedWafArn : { Type: String }
35+ SharedAlbDualstackDnsName : { Type: String }
3436
3537Conditions :
3638 IsProduction : !Equals [!Ref EnvironmentType, Production]
@@ -474,6 +476,144 @@ Resources:
474476 Threshold : 10
475477 TreatMissingData : notBreaching
476478
479+ Certificate :
480+ Type : AWS::CertificateManager::Certificate
481+ Properties :
482+ DomainName : !If [IsProduction, theworld.org, stag.theworld.org]
483+ SubjectAlternativeNames :
484+ Fn::If :
485+ - IsProduction
486+ - - frontend.theworld.org
487+ - frontend.prod.theworld.org
488+ - - frontend.stag.theworld.org
489+ Tags :
490+ - { Key: Name, Value: !Sub "${AWS::StackName} ${AWS::Region}" }
491+ - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
492+ - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
493+ - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
494+ - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
495+ - { Key: prx:dev:family, Value: The World }
496+ - { Key: prx:dev:application, Value: Website }
497+ ValidationMethod : DNS
498+
499+ NextStaticCachePolicy :
500+ Type : AWS::CloudFront::CachePolicy
501+ Properties :
502+ CachePolicyConfig :
503+ DefaultTTL : 60 # 1 day (default)
504+ MaxTTL : 31536000 # 1 year (default)
505+ MinTTL : 30 # 5 minutes
506+ Name : !Sub ${AWS::StackName}-frontend-cache-policy
507+ ParametersInCacheKeyAndForwardedToOrigin :
508+ CookiesConfig :
509+ CookieBehavior : none
510+ EnableAcceptEncodingBrotli : true
511+ EnableAcceptEncodingGzip : true
512+ HeadersConfig :
513+ HeaderBehavior : whitelist
514+ Headers :
515+ - host
516+ QueryStringsConfig :
517+ QueryStringBehavior : none
518+ AggresiveCachePolicy :
519+ Type : AWS::CloudFront::CachePolicy
520+ Properties :
521+ CachePolicyConfig :
522+ DefaultTTL : 86400 # 1 day (default)
523+ MaxTTL : 31536000 # 1 year (default)
524+ MinTTL : 600 # 5 minutes
525+ Name : !Sub ${AWS::StackName}-cache-policy
526+ ParametersInCacheKeyAndForwardedToOrigin :
527+ CookiesConfig :
528+ CookieBehavior : none
529+ EnableAcceptEncodingBrotli : true
530+ EnableAcceptEncodingGzip : true
531+ HeadersConfig :
532+ HeaderBehavior : whitelist
533+ Headers :
534+ - host
535+ QueryStringsConfig :
536+ QueryStringBehavior : whitelist
537+ QueryStrings :
538+ - ver
539+ OriginRequestPolicy :
540+ Type : AWS::CloudFront::OriginRequestPolicy
541+ Properties :
542+ # The headers, cookies, and query strings that are included in the
543+ # CACHE KEY (CachePolicyConfig) are also included in requests that
544+ # CloudFront sends to the origin.
545+ OriginRequestPolicyConfig :
546+ CookiesConfig :
547+ CookieBehavior : none
548+ # Cookies:
549+ HeadersConfig :
550+ HeaderBehavior : none
551+ # Headers:
552+ Name : !Sub ${AWS::StackName}-origin-req-policy
553+ QueryStringsConfig :
554+ QueryStringBehavior : none
555+ # QueryStrings:
556+
557+ CloudFrontDistribution :
558+ Type : AWS::CloudFront::Distribution
559+ Properties :
560+ DistributionConfig :
561+ Aliases :
562+ Fn::If :
563+ - IsProduction
564+ - - theworld.org
565+ - frontend.theworld.org
566+ - frontend.prod.theworld.org
567+ - - stag.theworld.org
568+ - frontend.stag.theworld.org
569+ CacheBehaviors :
570+ # WordPress Preview
571+ - AllowedMethods : [GET, HEAD, OPTIONS]
572+ CachedMethods : [GET, HEAD, OPTIONS]
573+ CachePolicyId : !GetAtt NextStaticCachePolicy.Id
574+ Compress : true
575+ OriginRequestPolicyId : !GetAtt OriginRequestPolicy.Id
576+ PathPattern : " /_next/static/*"
577+ TargetOriginId : frontend-ecs
578+ ViewerProtocolPolicy : redirect-to-https
579+ Comment : !Sub The World ${EnvironmentType} frontend
580+ ConnectionMode : direct
581+ DefaultCacheBehavior :
582+ AllowedMethods : [GET, HEAD]
583+ CachedMethods : [GET, HEAD]
584+ CachePolicyId : !GetAtt AggresiveCachePolicy.Id
585+ Compress : true
586+ OriginRequestPolicyId : !GetAtt OriginRequestPolicy.Id
587+ TargetOriginId : frontend-ecs
588+ ViewerProtocolPolicy : redirect-to-https
589+ Enabled : true
590+ HttpVersion : http2and3
591+ IPV6Enabled : true
592+ Origins :
593+ - Id : frontend-ecs
594+ CustomOriginConfig :
595+ OriginProtocolPolicy : https-only
596+ OriginSSLProtocols : [TLSv1.2]
597+ DomainName : !Ref SharedAlbDualstackDnsName
598+ OriginCustomHeaders :
599+ - HeaderName : x-prx-alb-access-token
600+ HeaderValue : !Ref AlbAccessToken
601+ PriceClass : PriceClass_All
602+ ViewerCertificate :
603+ AcmCertificateArn : !Ref Certificate
604+ MinimumProtocolVersion : TLSv1.2_2021
605+ SslSupportMethod : sni-only
606+ WebACLId : !Ref SharedWafArn
607+ Tags :
608+ - { Key: prx:meta:tagging-version, Value: "2021-04-07" }
609+ - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
610+ - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId }
611+ - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName }
612+ - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId }
613+ - { Key: prx:ops:environment, Value: !Ref EnvironmentType }
614+ - { Key: prx:dev:family, Value: The World }
615+ - { Key: prx:dev:application, Value: Website }
616+
477617Outputs :
478618 EcrImageTag :
479619 Value : !Ref EcrImageTag
0 commit comments