Skip to content

Commit

Permalink
update grant error message and README
Browse files Browse the repository at this point in the history
  • Loading branch information
humanzz committed Sep 9, 2022
1 parent ea14e7e commit 58479b0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-neptune/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The following example shows enabling IAM authentication for a database cluster a
const cluster = new neptune.DatabaseCluster(this, 'Cluster', {
vpc,
instanceType: neptune.InstanceType.R5_LARGE,
iamAuthentication: true, // Optional - will be automatically set if you call grantConnect().
iamAuthentication: true, // Optional - will be automatically set if you call grantConnect() or grant().
});
const role = new iam.Role(this, 'DBRole', { assumedBy: new iam.AccountPrincipal(this.account) });
// Use one of the following statements to grant the role the necessary permissions
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-neptune/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export abstract class DatabaseClusterBase extends Resource implements IDatabaseC

public grant(grantee: iam.IGrantable, ...actions: string[]): iam.Grant {
if (this.enableIamAuthentication === false) {
throw new Error('Cannot grant actions as IAM authentication is not enabled');
throw new Error('Cannot grant permissions as IAM authentication is disabled');
}

this.enableIamAuthentication = true;
Expand Down
4 changes: 2 additions & 2 deletions packages/@aws-cdk/aws-neptune/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ describe('DatabaseCluster', () => {
});

// THEN
expect(() => { cluster.grantConnect(role); }).toThrow(/Cannot grant actions as IAM authentication is not enabled/);
expect(() => { cluster.grantConnect(role); }).toThrow(/Cannot grant permissions as IAM authentication is disabled/);
});

test('grant - enables IAM auth and grants specified actions to the grantee', () => {
Expand Down Expand Up @@ -618,7 +618,7 @@ describe('DatabaseCluster', () => {
});

// THEN
expect(() => { cluster.grant(role, 'neptune-db:ReadDataViaQuery', 'neptune-db:WriteDataViaQuery'); }).toThrow(/Cannot grant actions as IAM authentication is not enabled/);
expect(() => { cluster.grant(role, 'neptune-db:ReadDataViaQuery', 'neptune-db:WriteDataViaQuery'); }).toThrow(/Cannot grant permissions as IAM authentication is disabled/);
});

test('autoMinorVersionUpgrade is enabled when configured', () => {
Expand Down

0 comments on commit 58479b0

Please sign in to comment.