From 0f739671c4599b03006acd70da9ee520198099eb Mon Sep 17 00:00:00 2001 From: Chris Kalafarski Date: Wed, 23 Oct 2024 11:32:57 -0400 Subject: [PATCH] Add Beta redirect function --- spire/templates/apps/beta.yml | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/spire/templates/apps/beta.yml b/spire/templates/apps/beta.yml index 8fba75c4..d1574a64 100644 --- a/spire/templates/apps/beta.yml +++ b/spire/templates/apps/beta.yml @@ -66,6 +66,75 @@ Resources: Resource: !Sub arn:${AWS::Partition}:s3:::${BetaBucket}/* Sid: Grant read access to a CloudFront Origin Identity + RedirectFunction: + Type: AWS::Serverless::Function + Properties: + CodeUri: + Bucket: !Ref CodeS3Bucket + Key: !Ref RedirectLambdaCodeS3ObjectKey + Description: !Sub ${EnvironmentType} Beta redirect + Environment: + Variables: + EXCHANGE_HOSTNAME: !Ref ExchangeHostname + FEEDER_HOSTNAME: !Ref FeederHostname + PLAY_HOSTNAME: !Ref PlayHostname + FunctionUrlConfig: + AuthType: NONE + Handler: index.handler + MemorySize: 128 + Runtime: nodejs20.x + Tags: + prx:meta:tagging-version: "2021-04-07" + prx:cloudformation:stack-name: !Ref AWS::StackName + prx:cloudformation:stack-id: !Ref AWS::StackId + prx:cloudformation:root-stack-name: !Ref RootStackName + prx:cloudformation:root-stack-id: !Ref RootStackId + prx:ops:environment: !Ref EnvironmentType + prx:dev:application: Beta + Timeout: 8 + FtpServerAuthorizerFunctionElevatedErrorAlarm: + Type: AWS::CloudWatch::Alarm + Condition: IsProduction + Properties: + AlarmName: !Sub WARN [Beta] Redirect function <${EnvironmentTypeAbbreviation}> INVOCATIONS ERRORS (${RootStackName}) + AlarmDescription: !Sub >- + ${EnvironmentType} Beta redirect is failing, so some traffic to the old + Beta domain may not be getting redirected to the correct place. + ComparisonOperator: GreaterThanThreshold + Dimensions: + - Name: FunctionName + Value: !Ref RedirectFunction + EvaluationPeriods: 1 + MetricName: Errors + Namespace: AWS/Lambda + Period: 60 + Statistic: Sum + Tags: + - { Key: prx:meta:tagging-version, Value: "2021-04-07" } + - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName } + - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId } + - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName } + - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId } + - { Key: prx:ops:environment, Value: !Ref EnvironmentType } + - { Key: prx:dev:application, Value: Beta } + Threshold: 0 + TreatMissingData: notBreaching + RedirectFunctionLogGroup: + Type: AWS::Logs::LogGroup + DeletionPolicy: Delete + UpdateReplacePolicy: Delete + Properties: + LogGroupName: !Sub /aws/lambda/${RedirectFunction} + RetentionInDays: 14 + Tags: + - { Key: prx:meta:tagging-version, Value: "2021-04-07" } + - { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName } + - { Key: prx:cloudformation:stack-id, Value: !Ref AWS::StackId } + - { Key: prx:cloudformation:root-stack-name, Value: !Ref RootStackName } + - { Key: prx:cloudformation:root-stack-id, Value: !Ref RootStackId } + - { Key: prx:ops:environment, Value: !Ref EnvironmentType } + - { Key: prx:dev:application, Value: Beta } + Outputs: DeployBucketRegionalDomainName: Value: !GetAtt BetaBucket.RegionalDomainName