Skip to content

Commit 6ecb774

Browse files
authored
Fixing Listener condition (#759)
* Fixing Listener condition * Splitting new LB and Lookup conditions check
1 parent f55bedb commit 6ecb774

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

ecs_composex/elbv2/elbv2_stack/elbv2.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,19 @@ def __init__(
7373
self.lookup_listeners: dict[int, LookupListener] = {}
7474
self.target_groups: list[MergedTargetGroup] = []
7575
super().__init__(name, definition, module, settings)
76+
if not keyisset("Listeners", definition) and not self.lookup:
77+
raise KeyError(
78+
"You must specify at least one new Listener for a new LB.", name
79+
)
80+
7681
if (
77-
not keyisset("Listeners", definition)
78-
and not self.lookup
79-
or (self.lookup and not keyisset("Listeners", self.lookup))
82+
self.lookup
83+
and not keyisset("Listeners", self.definition)
84+
and not keyisset("Listeners", self.lookup)
8085
):
81-
raise KeyError("You must specify at least one Listener for a LB.", name)
86+
raise KeyError(
87+
"When looking up LB, you must either create a new Listener or Lookup and existing one."
88+
)
8289

8390
self.cloud_control_attributes_mapping = LB_CLOUD_CONTROL_ATTRIBUTES
8491
self.no_allocate_eips: bool = keyisset("NoAllocateEips", self.settings)

0 commit comments

Comments
 (0)