[core] Cross-stack imports/exports don't support lists
When we define in Stack A a vpc endpoint and want to use the vpc endpoint in Stack B cdk automatically creates an Output and ImportValue. Sadly this does not work because CDK tries to export DnsEntries as a list which is not supported. In our case we used in Stack B the VPC endpoint for a Route 53 record.
Reproduction Steps
Stack A:
VpcEndpointService.Builder.create(this, "Test")
.acceptanceRequired(false).vpcEndpointServiceLoadBalancers(singletonList(nlb)).whitelistedPrincipals(
singletonList(new ArnPrincipal("arn:aws:iam::xxx:root")))
.build();
Stack B:
final ARecord aRecord = new ARecord(this, "Test", ARecordProps.builder()
.zone(hostedZone)
.recordName(recordName)
.target(RecordTarget.fromAlias(new InterfaceVpcEndpointTarget(vpcEndpoint))).build());
What did you expect to happen?
Output created in a compatible format
What actually happened?
Template format error: The Value field of every Outputs member must evaluate to a String.
Created template:
...
"ExportsOutputFnGetAttEndpoint380990D0DnsEntriesDE8B50BA": {
"Value": {
"Fn::GetAtt": [
"Endpoint380990D0",
"DnsEntries"
]
},
"Export": {
"Name": "Endpoint:ExportsOutputFnGetAttEndpoint380990D0DnsEntriesDE8B50BA"
}
},
...
Environment
- CLI Version : 1.49.1
- Framework Version: 1.49.1 | 1.56.0
- Node.js Version: 14.5.0
- OS : OSX Catalina
- Language (Version): Java 8
Other
Workaround
To solve this issue we manually exported dns entries: Stack A:
CfnOutput.Builder.create(this, "Test").exportName("VPCE-DNS")
.value(Fn.join(",", vpcEndpoint.getVpcEndpointDnsEntries())).build();
Stack B:
final String dnsName = Fn.select(1, Fn.split(":", Fn.select(0, Fn.split(",", Fn.importValue("VPCE-DNS")))));
...
"VPCEDNS": {
"Value": {
"Fn::Join": [
",",
{
"Fn::GetAtt": [
"Endpoint380990D0",
"DnsEntries"
]
}
]
},
"Export": {
"Name": "VPCE-DNS"
}
},
...
This is :bug: Bug Report
Is there any workarounds for this? I can't find a way to build RecordTarget using manually imported DNSName and HostedZoneId.
Sorry totally my mistake. I did not mention that we also needed to create records „manually“: https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-route53.CfnRecordSet.html
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.
This is still an issue.. When trying to share the dns entries for an interface endpoint. Is there any plan to fix this?