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(logs): add support for cloudwatch logs resource policy #17015

Merged

Conversation

nom3ad
Copy link
Contributor

@nom3ad nom3ad commented Oct 16, 2021

CloudFormation now supports Cloudwatch logs Resource policies
This PR adds L2 support for it.

And now its possible to grant access to service principals as follows. Previously this was throwing an error - see #5343

const eventsTargetLogs = new logs.LogGroup(this, 'EventsTargetLogGroup');
eventsTargetLogs.grantWrite(new iam.ServicePrincipal('events.amazonaws.com')).assertSuccess();

In future, following custom resource implementation of LogGroupResourcePolicy could be replaced.

export class LogGroupResourcePolicy extends cr.AwsCustomResource {

export class LogGroupResourcePolicy extends cr.AwsCustomResource {

export class LogGroupResourcePolicy extends cr.AwsCustomResource {

closes #5343


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 Oct 16, 2021

@nom3ad
Copy link
Contributor Author

nom3ad commented Oct 19, 2021

@rix0rrr Hey, Would you mind taking a look at this?

@peterwoodworth peterwoodworth changed the title feat(logs): add support for cloudwatch logs resource policy feat(logs): add support for cloudwatch logs resource policy Oct 21, 2021
@github-actions github-actions bot added the @aws-cdk/aws-logs Related to Amazon CloudWatch Logs label Oct 21, 2021
rix0rrr
rix0rrr previously approved these changes Oct 27, 2021
@mergify mergify bot dismissed rix0rrr’s stale review October 30, 2021 08:44

Pull request has been modified.

@nom3ad
Copy link
Contributor Author

nom3ad commented Oct 30, 2021

Oops! Forgot to add documentation to README. Sorry @rix0rrr, could you please reapprove?

@nom3ad nom3ad requested a review from rix0rrr October 30, 2021 11:00
@mergify
Copy link
Contributor

mergify bot commented Nov 1, 2021

Thank you for contributing! Your pull request will be updated from master 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: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 99e0fb0
  • 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 e9a461d into aws:master Nov 1, 2021
@mergify
Copy link
Contributor

mergify bot commented Nov 1, 2021

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

mergify bot pushed a commit that referenced this pull request Nov 9, 2021
…17403)

## Summary

This PR modifies the aws-logs `index.ts` file to also forward the exports from `policy.ts` ([a newly created file](#17015) that implements the `ResourcePolicy` class).

Fixes: #17402
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
CloudFormation now supports [Cloudwatch logs Resource policies](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-resourcepolicy.html)
This PR adds L2 support for it.

And now its possible to grant access to service principals as follows. Previously this was throwing an error - see aws#5343

```ts
const eventsTargetLogs = new logs.LogGroup(this, 'EventsTargetLogGroup');
eventsTargetLogs.grantWrite(new iam.ServicePrincipal('events.amazonaws.com')).assertSuccess();
```

In future, following custom resource implementation of `LogGroupResourcePolicy` could be replaced.

https://github.com/aws/aws-cdk/blob/83b8df8c390a27e10bf362f49babfb24ee425506/packages/@aws-cdk/aws-elasticsearch/lib/log-group-resource-policy.ts#L25
https://github.com/aws/aws-cdk/blob/a872e672f8990fc3879413e5d797533d3916e1fd/packages/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts#L26
https://github.com/aws/aws-cdk/blob/a872e672f8990fc3879413e5d797533d3916e1fd/packages/@aws-cdk/aws-events-targets/lib/log-group-resource-policy.ts#L26

closes aws#5343

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…ws#17403)

## Summary

This PR modifies the aws-logs `index.ts` file to also forward the exports from `policy.ts` ([a newly created file](aws#17015) that implements the `ResourcePolicy` class).

Fixes: aws#17402
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@seyeong seyeong mentioned this pull request Jun 24, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logs: Support Resource policies
3 participants