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(kinesis): support resource policy for a data stream #31909

Merged
merged 9 commits into from
Nov 1, 2024

Conversation

mazyu36
Copy link
Contributor

@mazyu36 mazyu36 commented Oct 25, 2024

Issue # (if applicable)

Closes #28814 .

Reason for this change

To support resource policy for a Kinesis Data stream.

Description of changes

  • Add ResourcePolicy Construct.
  • Add addToResourcePolicy method to Stream Construct.

Description of how you validated changes

Add unit tests and integ test.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 distinguished-contributor [Pilot] contributed 50+ PRs to the CDK labels Oct 25, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team October 25, 2024 17:04
@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Oct 26, 2024
@paulhcsun paulhcsun self-assigned this Oct 28, 2024
Copy link
Contributor

@paulhcsun paulhcsun left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution for this well requested feature @mazyu36! Just a few comments.

Comment on lines 202 to 234
```ts
const stream = new kinesis.Stream(this, 'MyStream');

// add resource policy
stream.addToResourcePolicy(new iam.PolicyStatement({
resources: [stream.streamArn],
actions: ['kinesis:GetRecords'],
principals: [new iam.AnyPrincipal()],
}));
```

A policy document can also be passed on `ResourcePolicy` construction

```ts
const stream = new kinesis.Stream(this, 'MyStream');

const policyDocument = new iam.PolicyDocument({
assignSids: true,
statements: [
new iam.PolicyStatement({
actions: ['kinesis:GetRecords'],
resources: [stream.streamArn],
principals: [new iam.AnyPrincipal()],
}),
],
});

// create resource policy
new kinesis.ResourcePolicy(this, 'ResourcePolicy', {
stream,
policyDocument,
});
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Would prefer to add a couple of sentences explicitly stating that the first example is Creating a ResourcePolicy using addToResourcePolicyand the second beingCreating a ResourcePolicy manually.

The sentence A policy document can also be passed on ResourcePolicy construction is also a little bit confusing, are we saying that you must pass a policy document when manually creating a ResourcePolicy or that when manually creating a ResourcePolicy you can optionally pass in your own PolicyDocument?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. I've updated.

packages/aws-cdk-lib/aws-kinesis/lib/resource-policy.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-kinesis/lib/resource-policy.ts Outdated Show resolved Hide resolved
packages/aws-cdk-lib/aws-kinesis/lib/stream.ts Outdated Show resolved Hide resolved
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Oct 29, 2024
@mergify mergify bot dismissed paulhcsun’s stale review October 30, 2024 00:26

Pull request has been modified.

@mazyu36
Copy link
Contributor Author

mazyu36 commented Oct 30, 2024

@paulhcsun
Thank you for the review!
I've addressed the comments.

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Oct 30, 2024
paulhcsun
paulhcsun previously approved these changes Oct 31, 2024
@paulhcsun
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Oct 31, 2024

update

✅ Branch has been successfully updated

Copy link
Contributor

mergify bot commented Oct 31, 2024

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 aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Oct 31, 2024
@mergify mergify bot dismissed paulhcsun’s stale review October 31, 2024 23:01

Pull request has been modified.

@mazyu36
Copy link
Contributor Author

mazyu36 commented Oct 31, 2024

@Mergifyio update

Copy link
Contributor

mergify bot commented Oct 31, 2024

update

✅ Branch has been successfully updated

Copy link
Contributor

mergify bot commented Nov 1, 2024

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: 6490fd1
  • 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 18fbd6d into aws:main Nov 1, 2024
9 checks passed
Copy link
Contributor

mergify bot commented Nov 1, 2024

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).

Copy link

github-actions bot commented Nov 1, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2024
@mazyu36 mazyu36 deleted the kinesis-policy-28814 branch November 1, 2024 01:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cdk/kinesis: Data stream sharing
3 participants