Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(logs): ResourcePolicy does not have a defaultChild #21039

Merged
merged 2 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/@aws-cdk/aws-logs/lib/policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class ResourcePolicy extends Resource {
physicalName: props?.resourcePolicyName,
});

new CfnResourcePolicy(this, 'ResourcePolicy', {
const l1 = new CfnResourcePolicy(this, 'ResourcePolicy', {
policyName: Lazy.string({
produce: () => props?.resourcePolicyName ?? Names.uniqueId(this),
}),
Expand All @@ -55,6 +55,8 @@ export class ResourcePolicy extends Resource {
}),
});

this.node.defaultChild = l1;

if (props?.policyStatements) {
this.document.addStatements(...props.policyStatements);
}
Expand Down
11 changes: 11 additions & 0 deletions packages/@aws-cdk/aws-logs/test/policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,15 @@ describe('resource policy', () => {
PolicyName: 'ResourcePolicy',
});
});

test('ResourcePolicy has a defaultChild', () => {
// GIVEN
const stack = new Stack();

// WHEN
const resourcePolicy = new ResourcePolicy(stack, 'ResourcePolicy');

// THEN
expect(resourcePolicy.node.defaultChild).toBeDefined();
});
});