(elbv2): Cross stack references missing from BaseLoadBalancer
See original GitHub issueCan’t reference an ALB created in Account A on a Stack B in Account B to create R53 Record.
Reproduction Steps
const ENV1 = { account: '11111', region: 'us-east-1' };
const ENV2 = { account: '2222', region: 'eu-west-2' };
class ProducerStack extends Stack {
public readonly alb: ApplicationLoadBalancer;
constructor(scope: Construct, id: string) {
super(scope, id, { env: ENV1 });
this.alb = new elbv2.ApplicationLoadBalancer(this, 'ApplicationLoadBalancerPrivate', {
loadBalancerName: cdk.PhysicalName.GENERATE_IF_NEEDED,
});
}
}
interface ConsumerStackProps {
readonly alb: ApplicationLoadBalancer;
}
class ConsumerStack extends Stack {
constructor(scope: Construct, id: string, props: ConsumerStackProps) {
super(scope, id, { env: ENV2 });
new route53.ARecord(this, 'AliasRecord', {
zone,
target: route53.RecordTarget.fromAlias(new alias.LoadBalancerTarget(props.alb)),
});
}
}
const producer = new ProducerStack(app, 'producer');
const consumer = new ConsumerStack(app, 'consumer', {
alb: producer.alb
});
What did you expect to happen?
Using reference between Stacks/Accounts
What actually happened?
Error: Stack "B" cannot consume a cross reference from stack "A". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack
Other
Please see reference in https://github.com/aws/aws-cdk-rfcs/issues/226 with @skinny85 :
@Cloudrage you’re right. It turns out there’s some logic missing from
BaseLoadBalancer
that is required for making these references work.Do you mind creating us a bug for it in the main CDK repo? Thanks!
_Originally posted by @skinny85 in https://github.com/aws/aws-cdk-rfcs/issues/226#issuecomment-742178105_
This is 🐛 Bug Report
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
aws-cdk/aws-elasticloadbalancingv2 module
The reason is that these methods will create resources in the same Stack as the object they're called on, which may lead to...
Read more >@aws-cdk/aws-elasticloadbalancingv2 - Package Manager
Fast, reliable, and secure dependency management.
Read more >Fix error: cannot consume a cross reference from stack in ...
You try to reference another stack that is in a different AWS region. Note: cross region references aren't supported. · You aren't passing...
Read more >awselasticloadbalancingv2 - Go Packages
Properties to reference an existing load balancer. Example: // The code below shows an example of how to instantiate this type. // The...
Read more >software.amazon.awscdk:config: Versions | Openbase
outDir (#11729) (1000cf9); lambda-nodejs: maximum call stack size exceeded or ... with cross-stack buckets cause cyclic references (#10696) (0ec4588), ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@njlynch , not really integrated and native 😕 That’s why the Feature Request is very important in a multi-account strategy.
@njlynch yes, you’re right, and that’s probably why we didn’t add it originally 😕. If the ARN cannot be derived from the name in a stable way, we can’t use these facilities for cross-environments references.
Sorry @Cloudrage . Looks like your feature request is still needed then.