Skip to content

Commit

Permalink
fix: flowlog has no default child (#21045)
Browse files Browse the repository at this point in the history
Calling defaultChild on `FlowLog` results in undefined. Explicitly set CfnResource as default child

----

### All Submissions:

* [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
peterwoodworth authored Jul 7, 2022
1 parent a171bf6 commit b025abc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ec2/lib/vpc-flow-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,5 +510,6 @@ export class FlowLog extends FlowLogBase {
});

this.flowLogId = flowLog.ref;
this.node.defaultChild = flowLog;
}
}
10 changes: 10 additions & 0 deletions packages/@aws-cdk/aws-ec2/test/vpc-flow-logs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b025abc

Please sign in to comment.