Skip to content

Commit

Permalink
Adds redirect to Metrics host-header rule
Browse files Browse the repository at this point in the history
  • Loading branch information
farski committed Oct 16, 2023
1 parent 5358958 commit 39dbe5f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions spire/templates/apps-300A.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Parameters:
AdFilesHostname: { Type: String }
AuguryHostname: { Type: String }
FeederHostname: { Type: String }
MetricsHostname: { Type: String }
DovetailCdnHostname: { Type: String }
CmsHostname: { Type: String }
TheCountHostname: { Type: String }
Expand Down Expand Up @@ -207,6 +208,7 @@ Resources:
CloudWatchAlarmTaggerServiceToken: !Ref CloudWatchAlarmTaggerServiceToken
CastleHostname: !Ref CastleHostname
IdHostname: !Ref IdHostname
MetricsHostname: !Ref MetricsHostname
Tags:
- { Key: prx:meta:tagging-version, Value: "2021-04-07" }
- { Key: prx:cloudformation:stack-name, Value: !Ref AWS::StackName }
Expand Down
22 changes: 22 additions & 0 deletions spire/templates/apps/metrics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ Parameters:
AlbListenerRulePriorityPrefix: { Type: String }
CastleHostname: { Type: String }
IdHostname: { Type: String }
MetricsHostname: { Type: String }

Conditions:
IsProduction: !Equals [!Ref EnvironmentType, Production]
IsStaging: !Equals [!Ref EnvironmentType, Staging]

Resources:
HostHeaderListenerRule:
Expand All @@ -46,6 +48,7 @@ Resources:
Priority: !Join ["", [!Ref AlbListenerRulePriorityPrefix, "00"]]
AltHostHeaderListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Condition: IsProduction
Properties:
Actions:
- TargetGroupArn: !Ref TargetGroup
Expand All @@ -56,6 +59,25 @@ Resources:
- metrics.*
ListenerArn: !Ref AlbHttpsListenerArn
Priority: !Join ["", [!Ref AlbListenerRulePriorityPrefix, "01"]]
RedirectHostHeaderListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Condition: IsStaging
Properties:
Actions:
- RedirectConfig:
Host: !Ref MetricsHostname
Path: "/#{path}"
Port: "#{port}"
Protocol: "#{protocol}"
Query: "#{query}"
StatusCode: "HTTP_301"
Type: redirect
Conditions:
- Field: host-header
Values:
- metrics.*
ListenerArn: !Ref AlbHttpsListenerArn
Priority: !Join ["", [!Ref AlbListenerRulePriorityPrefix, "02"]]

TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Expand Down
1 change: 1 addition & 0 deletions spire/templates/root.yml
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ Resources:
AdFilesHostname: !GetAtt Constants2.Outputs.AdFilesHostname
AuguryHostname: !GetAtt Constants2.Outputs.AuguryHostname
FeederHostname: !GetAtt Constants2.Outputs.FeederHostname
MetricsHostname: !GetAtt Constants2.Outputs.MetricsHostname
CmsHostname: !GetAtt Constants2.Outputs.CmsHostname
DovetailCdnHostname: !GetAtt Constants2.Outputs.DovetailCdnHostname
DovetailRouterHostname: !GetAtt Constants2.Outputs.DovetailRouterHostname
Expand Down

0 comments on commit 39dbe5f

Please sign in to comment.