diff --git a/packages/@aws-cdk/aws-ec2/lib/vpc-flow-logs.ts b/packages/@aws-cdk/aws-ec2/lib/vpc-flow-logs.ts index 3c0dcbe1053b9..c027d4424ccd4 100644 --- a/packages/@aws-cdk/aws-ec2/lib/vpc-flow-logs.ts +++ b/packages/@aws-cdk/aws-ec2/lib/vpc-flow-logs.ts @@ -510,5 +510,6 @@ export class FlowLog extends FlowLogBase { }); this.flowLogId = flowLog.ref; + this.node.defaultChild = flowLog; } } diff --git a/packages/@aws-cdk/aws-ec2/test/vpc-flow-logs.test.ts b/packages/@aws-cdk/aws-ec2/test/vpc-flow-logs.test.ts index 3063a53a22fd6..ce27cd5f0eb30 100644 --- a/packages/@aws-cdk/aws-ec2/test/vpc-flow-logs.test.ts +++ b/packages/@aws-cdk/aws-ec2/test/vpc-flow-logs.test.ts @@ -442,6 +442,16 @@ describe('vpc flow logs', () => { }, }); }); + test('flowlog has defaultchild', () => { + const stack = new Stack(); + const vpc = new Vpc(stack, 'VPC'); + + const flowlog = new FlowLog(stack, 'FlowLog', { + resourceType: FlowLogResourceType.fromVpc(vpc), + }); + + expect(flowlog.node.defaultChild).toBeDefined(); + }); }); function getTestStack(): Stack {