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

chore(logs): Adding a public method to access the physical name of the log group #14947

Merged
merged 3 commits into from
Jun 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions packages/@aws-cdk/aws-logs/lib/log-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ export interface ILogGroup extends IResource {
* Give the indicated permissions on this log group and all streams
*/
grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant;

/**
* Public method to get the physical name of this log group
*/
logGroupPhysicalName(): string;
}

/**
Expand Down Expand Up @@ -173,6 +178,14 @@ abstract class LogGroupBase extends Resource implements ILogGroup {
scope: this,
});
}

/**
* Public method to get the physical name of this log group
* @returns Physical name of log group
*/
public logGroupPhysicalName(): string {
return this.physicalName;
}
}

/**
Expand Down
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-logs/test/test.loggroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,24 @@ export = {

test.done();
},

'correctly returns physical name of the log group'(test: Test) {
// GIVEN
const stack = new Stack();

// WHEN
const logGroup = new LogGroup(stack, 'LogGroup', {
logGroupName: 'my-log-group',
});

// THEN
test.equal(logGroup.logGroupPhysicalName(), 'my-log-group');
expect(stack).to(haveResource('AWS::Logs::LogGroup', {
LogGroupName: 'my-log-group',
}));

test.done();
},
};

function dataDrivenTests(cases: any[][], body: (test: Test, ...args: any[]) => void) {
Expand Down