Closed markusl closed 5 years ago
What if you don't use fromApplicationListenerAttributes
but just use the listener directly in stack 2?
@rix0rrr thanks for the tip. Didn't even think it could be that easy. Here's the problem with that one:
Error: 'ApplicationName-Stack2' depends on 'ApplicationName-Stack1'
(ApplicationName-Stack2/ApplicationName-Stack2-ContainerName/Service ->
ApplicationName-Stack1/ApplicationName-Stack1LoadBalancer/ApplicationName-Stack1HttpsListener/ApplicationName-Stack2-ContainerNameGroup/Resource.Ref).
Adding this dependency (ApplicationName-Stack1/ApplicationName-Stack1LoadBalancer/SecurityGroup/to SecurityGroup997F5017:8080 -> ApplicationName-Stack2/ApplicationName-Stack2-ContainerName/SecurityGroup/Resource.GroupId) would create a cyclic reference.```
I think you are now getting hit by the issue that was fixed in https://github.com/aws/aws-cdk/pull/4111.
The fix for that will be rolling out later today in the new release. Sorry to keep you waiting.
I can now confirm that this is fixed. Thanks for the help :)
@rix0rrr thanks for the tip. Didn't even think it could be that easy. Here's the problem with that one:
Error: 'ApplicationName-Stack2' depends on 'ApplicationName-Stack1' (ApplicationName-Stack2/ApplicationName-Stack2-ContainerName/Service -> ApplicationName-Stack1/ApplicationName-Stack1LoadBalancer/ApplicationName-Stack1HttpsListener/ApplicationName-Stack2-ContainerNameGroup/Resource.Ref). Adding this dependency (ApplicationName-Stack1/ApplicationName-Stack1LoadBalancer/SecurityGroup/to SecurityGroup997F5017:8080 -> ApplicationName-Stack2/ApplicationName-Stack2-ContainerName/SecurityGroup/Resource.GroupId) would create a cyclic reference.```
Does it work in CDK v2? Can you please share an example? Can't get it working today
I'm facing the same issue in v2 as well. Couldn't find a solution yet.
I believe I'm also facing the same issue in v2 using the same method originally suggested by @rix0rrr
Actually I think I found the way around, at least for me, instead of using
loadBalancerListener.addAction('Action', {
priority,
conditions: [ListenerCondition.hostHeaders([domainName])],
action: ListenerAction.forward([this.targetGroup])
});
this seems to work
new ApplicationListenerRule(this, 'ListenerRule', {
listener: loadBalancerListener,
priority,
action: ListenerAction.forward([this.targetGroup]),
conditions: [ListenerCondition.hostHeaders([domainName])],
});
Cyclic dependency issue still exists in CDK v2
:question: General Issue
Since hitting CloudFormation 200 resource limit, I have been trying to refactor our services to multiple stacks sharing ALB between the stacks.
However, it seems importing ALB or ALB listener between stacks and adding more services to it is challenging.
Stack1 - Create stack and ALB with listener
Stack 2 - Trying to import existing listener to add new services
Result
The result of trying to do that is following:
Error: Can only call addTargets() when using a constructed ApplicationListener; construct a new TargetGroup and use addTargetGroup.
Do you have any example or recommendations about how to do this? In general it does not feel right to work around CF limitations in this way..
Environment