From 8e7904457017c51ff9491b09644a2e3d3e1f54b3 Mon Sep 17 00:00:00 2001 From: Tim Hassett Date: Fri, 15 Feb 2019 12:31:25 +1100 Subject: [PATCH] Added optional name key for ListenerRules --- ecs-service.cfndsl.rb | 10 +++++++++- ecs-service.config.yaml | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ecs-service.cfndsl.rb b/ecs-service.cfndsl.rb index ffebea0..3234605 100644 --- a/ecs-service.cfndsl.rb +++ b/ecs-service.cfndsl.rb @@ -251,7 +251,15 @@ listener_conditions << { Field: "host-header", Values: hosts } end - ElasticLoadBalancingV2_ListenerRule("TargetRule#{rule['priority']}") do + if rule.key?("name") + rule_name = rule['name'] + elsif rule['priority'].is_a? Integer + rule_name = "TargetRule#{rule['priority']}" + else + rule_name = "TargetRule#{index}" + end + + ElasticLoadBalancingV2_ListenerRule(rule_name) do Actions [{ Type: "forward", TargetGroupArn: Ref('TaskTargetGroup') }] Conditions listener_conditions ListenerArn Ref("Listener") diff --git a/ecs-service.config.yaml b/ecs-service.config.yaml index 06e719d..f7876cd 100644 --- a/ecs-service.config.yaml +++ b/ecs-service.config.yaml @@ -50,7 +50,8 @@ log_retention: 7 # path: /status # code: 200 # rules: -# - path: /v2/* +# - name: apiv2 +# path: /v2/* # host: api.* # priority: 10 # - path: /api/v1/*