mu icon indicating copy to clipboard operation
mu copied to clipboard

Support Multiple ALB Path Patterns in mu.yml

Open craigtsmith opened this issue 6 years ago • 1 comments

Description Currently mu only supports one path pattern for the service ALB, as the generation of the CloudFormation template passes your mu.yml pathPatterns: array directly into the AWS::ElasticLoadBalancingV2::ListenerRule > Conditions > Values property, which despite it's name only accepts one path pattern.

If mu's internals are refactored slightly to generate a new ElbHttp(s)PathListenerRule for each path pattern in mu.yml and the pathPatterns: node n mu.yml is changed from an array to a map, it should be possible to support this use case and preserve the ability to target rules in Cfn, eg:

service:
  name: my-service
  port: 80

  pathPatterns:
    app: /app*
    assets: /assets*

Could become the following Cfn

ElbHttpPathListenerRule-app:
  Condition: HasElbHttpPathListener
  Properties:
    Actions:
    - TargetGroupArn:
        Ref: ElbTargetGroup
      Type: forward
    Conditions:
    - Field: path-pattern
      Values:
        Ref: /app*
    ListenerArn:
      Fn::ImportValue:
        Fn::Sub: ${ElbHttpListenerArn}
    Priority:
      Ref: PathListenerRulePriority
  Type: AWS::ElasticLoadBalancingV2::ListenerRule
ElbHttpPathListenerRule-assets:
  Condition: HasElbHttpPathListener
  Properties:
    Actions:
    - TargetGroupArn:
        Ref: ElbTargetGroup
      Type: forward
    Conditions:
    - Field: path-pattern
      Values:
        Ref: /assets*
    ListenerArn:
      Fn::ImportValue:
        Fn::Sub: ${ElbHttpListenerArn}
    Priority:
      Ref: PathListenerRulePriority
  Type: AWS::ElasticLoadBalancingV2::ListenerRule

craigtsmith avatar Jan 08 '19 17:01 craigtsmith

I think the priority should be specified for each path, so maybe:

pathPatterns:
  - name: app
    pathPattern: /app*
    priority: 100
  - name: assets
    pathPattern: /assets*
    priority: 200

srp avatar Feb 22 '19 19:02 srp