-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cross stack vpc causes unresolved resource dependencies error #4474
Comments
This is a blocking issue to organize large infra by nested stacks. Any fix ETA? |
Unfortunately we don't have an ETA yet. To work around issues this problem is causing for you, you can try using the escape hatch mechanism. |
I ran into this issue as well. It seems like it has something to do with |
Apologies for the confusion, managed to reproduce this in 1.18.0: import { Stack, App } from '@aws-cdk/core';
import ec2 = require('@aws-cdk/aws-ec2');
import elb = require('@aws-cdk/aws-elasticloadbalancingv2');
const app = new App();
const root = new Stack(app, 'Root');
const stack1 = new Stack(root, 'Network');
const vpc = new ec2.Vpc(stack1, 'Vpc');
const stack2 = new Stack(root, 'Instances');
new elb.ApplicationLoadBalancer(stack2, 'LoadBalancer', {
vpc,
internetFacing: true
});
app.synth(); Validated that this is going to be resolved by #5211 |
* fix(cloudformation): dependencies across nested stack boundaries When adding dependencies of any kind (`node.addDependency`, `stack.addDependency` or `cfnResource.addDependsOn`), we now take nested stacks into account and transfer the dependency to the lowest common scope (either a common stack or the assembly). This is primarily implemented in `cfnResource.addDependsOn` and `stack.addDependency` through the following algorithm: - Lookup the lowest common stack - If not found, apply the dependency at the assembly level (between two top-level stacks). - If found, identify the two CloudFormation resources which represent this relationship within the scope of the common stack (this could be the actual resource if they are both in the same stack or the `AWS::CloudFormation::Stack` resource if the source or target are with in a nested stack). - Apply the dependency at the CloudFormation level (add `DependsOn`). There are a bunch of edge cases as well. To be able to find the AWS::CloudFormation::Stack resource for nested stacks, the `nestedStackResource` property was added to `core.Stack` and assigned by `NestedStack`. It seems like we should probably move `NestedStack` from the `aws-cloudformation` module and into `core` since there is too much coupling right now. Created a thorough test suite to examine various cases under `test.deps.ts`. Note that this suite includes tests for nested stacks and for regular cases, but decided to put them all in a single suite to make it easier to reason about coverage. Fixes #4460 * validate #4474 * combine stack and resource deps into a single algorithm - Rewrote the `addDependency` algorithm generically to support defining dependencies between two resources or two stacks. - Added a cache for `Stack.of` which is expected to have some nice gains since this method is widely used, especially around these algorithms. * rename `parentStack` to `nestedStackParent` * hide the Stack.of cache property * convert nestedStackParent to a getter * fix compilation error
@eladb is this set for a 1.19.0 release? |
I can confirm this is fixed in master. I did a full build and linked dependencies into a project last night.
|
Hi,
creating a vpc in a child stack (not nested), and creating some resources, that depend on the vpc, in another child stack will result in a ValidationError.
I was able to reproduce this with application loadbalancers (only internet facing) aswell as an aurora cluster (public and private).
Reproduction Steps
Error Log
Environment
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: