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.59k stars 3.89k forks source link

(aws-route53-targets (or aws-route53 or aws-ec2)): No child with id: 'Resource'` when referencing existing vpc endpoint in route 53 arecord #16544

Closed aherrmann13 closed 2 years ago

aherrmann13 commented 3 years ago

:question: General Issue

No child with id: 'Resource' when referencing existing vpc endpoint in route 53 arecord

getting error No child with id: 'Resource' with the code below

// not the actual values
const vpcEndpointId = 'some endpoint id that I have verified exists'
const recordName = 'my record name'

const endpoint = InterfaceVpcEndpoint.fromInterfaceVpcEndpointAttributes(this, "VPCEndpoint", {
    vpcEndpointId: vpcEndpointId,
    port: 443
})
const hostedZone = new PrivateHostedZone(this, "HostedZone", { vpc, zoneName: dependency.dns });

new ARecord(this, `ARecord`, {
    zone: hostedZone,
    target: RecordTarget.fromAlias(new InterfaceVpcEndpointTarget(endpoint)),
    recordName: recordName
});

seems to be failing on the line here

this works fine when I create a VPC endpoint but when I reference an existing endpoint it breaks

context on the problem: there is an external service that takes care of configuring cross region private links, so for same region private links I want to configure in the cdk and for cross region I want to reference the vpc endpoint that was created for me in my aws account

Environment

Other information

I can't share the source code to make it easier to repro, let me know if you need any more information

peterwoodworth commented 3 years ago

Hey @aherrmann13, thanks for submitting this issue.

This is a bug, an imported resource shouldn't have children. The InterfaceVpcEndpointTarget class should only take in an InterfaceVpcEndpoint instead of an IInterfaceVpcEndpoint. Either that, or the pattern should be reworked to function with imported resources. @njlynch what do you think?

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.