aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.62k stars 3.91k forks source link

[core] transparent cross-stack references don't work in overrides #9112

Closed RomainMuller closed 2 years ago

RomainMuller commented 4 years ago

When making a cross-stack reference in a property override, the cross-stack references do not get processed into an export/import pair, and result in an invalid template.

This is effectively preventing usage of property overrides to work around the deficiencies of the VPC class if the VPC instance is in a separate stack.

Reproduction Steps

I've created a simple (enough) repro of this issue here: RomainMuller/cdk-cross-stack-bug:test/cdk-cross-stack-bug.test.ts

Environment


This is :bug: Bug Report

paveljos commented 4 years ago

I encountered this myself in adding a work-around to implement EFS support for an ECS task - I could see this being a frequent issue if anybody needs to utilize the "Escape Hatch" for new features supported by Cloudformation.

DarkmatterVale commented 3 years ago

I just encountered this when attempting to place a CloudWatch Synthetics Canary inside of an isolated VPC using an escape hatch:

const canaryCfn = canary.node.defaultChild as CfnCanary;
canaryCfn.addPropertyOverride("VPCConfig.VpcId", props.vpc.vpcId);
canaryCfn.addPropertyOverride("VPCConfig.SubnetIds", props.subnetIds);
canaryCfn.addPropertyOverride("VPCConfig.SecurityGroupIds", props.vpc.vpcDefaultSecurityGroup);

Where I'm passing a vpc that was created in a different stack.

The previous code results in Error [ValidationError]: Template error: instance of Fn::GetAtt references undefined resource ... during CDK deployment.

I'm using CDK v1.91.0 with Typescript.

tkrajca commented 3 years ago

Hi, same here, any workarounds?

github-actions[bot] commented 2 years ago

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

davispuh commented 2 years ago

This is still an issue, how can it be worked around?

davispuh commented 2 years ago

Figured it out, you can use stack.exportValue() to get resolved reference.