in src/main/java/jetbrains/teamcity/aws/template/services/ecs/AwsTeamCityTemplateEcs.java [87:109]
private void addCustomHttpHeaderRequirement(@NotNull final Construct scope) {
ApplicationListenerRule.Builder.create(scope, "CustomHeaderRuleForAlbRestriction")
.listener(myApplicationLoadBalancedFargateService.getListener())
.priority(1)
.conditions(Collections.singletonList(
ListenerCondition.httpHeader(CUSTOM_HTTP_HEADER_FOR_ALB_RESTRICTION, Collections.singletonList(CUSTOM_HTTP_HEADER_FOR_ALB_RESTRICTION_VALUE))
))
.action(ListenerAction.forward(Collections.singletonList(myApplicationLoadBalancedFargateService.getTargetGroup())))
.build();
CfnListener defaultListener = (CfnListener) myApplicationLoadBalancedFargateService.getListener().getNode().getDefaultChild();
assert defaultListener != null;
defaultListener.setDefaultActions(Collections.singletonList(
CfnListener.ActionProperty.builder()
.type("fixed-response")
.fixedResponseConfig(CfnListener.FixedResponseConfigProperty.builder()
.statusCode("403")
.contentType("text/html")
.messageBody("Access denied")
.build())
.build())
);
}