Skip to content

feat(kinesis): support resource policy for a data stream#31909

Merged
mergify[bot] merged 9 commits intoaws:mainfrom
mazyu36:kinesis-policy-28814
Nov 1, 2024
Merged

feat(kinesis): support resource policy for a data stream#31909
mergify[bot] merged 9 commits intoaws:mainfrom
mazyu36:kinesis-policy-28814

Conversation

@mazyu36
Copy link
Copy Markdown
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
@mazyu36 mazyu36 force-pushed the kinesis-policy-28814 branch from f2be286 to 07a5140 Compare October 26, 2024 02:42
@mazyu36 mazyu36 force-pushed the kinesis-policy-28814 branch from 07a5140 to c2d91b7 Compare October 26, 2024 03:16
@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
Copy Markdown
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,
});
``` No newline at end of file
Copy link
Copy Markdown
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
Copy Markdown
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.

@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
mazyu36 and others added 3 commits October 30, 2024 09:25
Co-authored-by: paulhcsun <47882901+paulhcsun@users.noreply.github.com>
Co-authored-by: paulhcsun <47882901+paulhcsun@users.noreply.github.com>
Co-authored-by: paulhcsun <47882901+paulhcsun@users.noreply.github.com>
@mergify mergify bot dismissed paulhcsun’s stale review October 30, 2024 00:26

Pull request has been modified.

@mazyu36
Copy link
Copy Markdown
Contributor Author

mazyu36 commented Oct 30, 2024

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

@mazyu36 mazyu36 requested a review from paulhcsun October 30, 2024 00:45
@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
Copy Markdown
Contributor

@Mergifyio update

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 31, 2024

update

✅ Branch has been successfully updated

@mergify
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

mazyu36 commented Oct 31, 2024

@Mergifyio update

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Oct 31, 2024

update

✅ Branch has been successfully updated

@mergify
Copy link
Copy Markdown
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
Copy Markdown
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
@mergify
Copy link
Copy Markdown
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).

@github-actions
Copy link
Copy Markdown
Contributor

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