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

feat(neptune): introduce cluster grant method for granular actions #21926

Merged
merged 7 commits into from
Sep 9, 2022

Conversation

humanzz
Copy link
Contributor

@humanzz humanzz commented Sep 6, 2022

#21877

This PR is split from #21908 as per the discussion with @TheRealAmazonKendra

All Submissions:

Adding new Unconventional Dependencies:

  • This PR adds new unconventional dependencies following the process described here

New Features

  • Have you added the new feature to an integration test?
    • 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

@gitpod-io
Copy link

gitpod-io bot commented Sep 6, 2022

@aws-cdk-automation aws-cdk-automation requested a review from a team September 6, 2022 08:31
@github-actions github-actions bot added the p2 label Sep 6, 2022
@humanzz humanzz changed the title feat(neptune): introduce cluster grant method for granular actions chore(neptune): introduce cluster grant method for granular actions Sep 6, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good for the most part. I'd like to see the new grant functions used in integration tests somewhere.

packages/@aws-cdk/aws-neptune/lib/cluster.ts Outdated Show resolved Hide resolved
@humanzz humanzz force-pushed the neptune-cluster-grant branch from c954ae6 to 6fddb0c Compare September 7, 2022 21:51
@mergify mergify bot dismissed TheRealAmazonKendra’s stale review September 7, 2022 21:51

Pull request has been modified.

@humanzz
Copy link
Contributor Author

humanzz commented Sep 7, 2022

This looks good for the most part. I'd like to see the new grant functions used in integration tests somewhere.

Let's do that after the other PR is merged to avoid conflicts in integ tests.

@humanzz humanzz changed the title chore(neptune): introduce cluster grant method for granular actions feat(neptune): introduce cluster grant method for granular actions Sep 8, 2022
Copy link
Contributor

@TheRealAmazonKendra TheRealAmazonKendra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two very minor things inline.

if (this.enableIamAuthentication === false) {
throw new Error('Cannot grant connect when IAM authentication is disabled');
throw new Error('Cannot grant actions as IAM authentication is not enabled');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new Error('Cannot grant actions as IAM authentication is not enabled');
throw new Error('Cannot grant permissions when IAM authentication is not enabled');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question here, the README says:

const cluster = new neptune.DatabaseCluster(this, 'Cluster', {
  vpc,
  instanceType: neptune.InstanceType.R5_LARGE,
  iamAuthentication: true, // Optional - will be automatically set if you call grantConnect().
});

It seems that this sort of contradicts that. Can you add a clarifying line that explicitly setting this to false and trying to grant permissions will throw an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tbh, I found the existing implementation of grantConnect and its side effect of possibly enabling iam auth, and how enabling iamAuth is handled a bit surprising!

https://github.com/aws/aws-cdk/blob/main/packages/%40aws-cdk/aws-neptune/lib/cluster.ts#L368

In terms of the error message, now that I look at it, I think the older version that uses "disabled" actually makes more sense and is more consistent with the implemented behaviour which

  1. Defaults to disabled (I think a cloudformation default rather than a cdk default)
  2. Requires one to explicitly disable iam auth if they don't want it and want grant methods to throw such exceptions

I get that grant enabling iam auth might be a convenience, but it's a bit twisted IMHO!

So, for this PR, how about

  1. change the error message to Cannot grant permissions when IAM authentication is disabled
  2. update the README to say // Optional - will be automatically set if you call grant() or grantConnect()

@mergify mergify bot dismissed TheRealAmazonKendra’s stale review September 9, 2022 18:18

Pull request has been modified.

@mergify
Copy link
Contributor

mergify bot commented Sep 9, 2022

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 3d369be
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit 42e559d into aws:main Sep 9, 2022
Kruspe pushed a commit to DavidSchwarz2/aws-cdk that referenced this pull request Sep 13, 2022
…ws#21926)

- neptune engine version 1.2.0.0 introduced more granular access control https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html
- introduce grant method to facilitate working with different actions

aws#21877 
----

This PR is split from aws#21908 as per the discussion with @TheRealAmazonKendra 

### All Submissions:

* [x] 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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants