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

chore(cloudtrail): better typed event selector apis #8097

Merged
merged 3 commits into from
May 27, 2020

Conversation

nija-at
Copy link
Contributor

@nija-at nija-at commented May 20, 2020

Commit Message

chore(cloudtrail): better typed event selector apis (#8097)

The event selector APIs now take strongly typed IFunction and
IBucket instead of a string that is expected to contain the ARN.

Additionally, add APIs to log all S3 data events and to log all Lambda
data events.

Change the type of snsTopic from string to ITopic.

BREAKING CHANGE: API signatures of addS3EventSelectors and
addLambdaEventSelectors have changed. Their parameters are now
strongly typed to accept IBucket and IFunction respectively.

  • cloudtrail: addS3EventSelectors and addLambdaEventSelectors
    can no longer be used to configure all S3 data events or all Lambda data
    events. Two new APIs logAllS3DataEvents() and
    logAllLambdaDataEvents() have been introduced to achieve this.
  • cloudtrail: The property snsTopic is now of the type ITopic.

End Commit Message


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

The event selector APIs now take strongly typed `IFunction` and
`IBucket` instead of a string that is expected to contain the ARN.

Additionally, add APIs to log all S3 data events and to log all Lambda
data events.

Change the type of `snsTopic` from `string` to `ITopic`.

BREAKING CHANGE: API signatures of `addS3EventSelectors` and
`addLambdaEventSelectors` have changed. Their parameters are now
strongly typed to accept `IBucket` and `IFunction` respectively.
* **cloudtrail:** `addS3EventSelectors` and `addLambdaEventSelectors`
can no longer be used to configure all S3 data events or all Lambda data
events. Two new APIs `logAllS3DataEvents()` and
`logAllLambdaDataEvents()` have been introduced to achieve this.
* **cloudtrail:** The property `snsTopic` is now of the type `ITopic`.
@nija-at nija-at requested a review from rix0rrr May 20, 2020 11:47
@nija-at nija-at self-assigned this May 20, 2020
@nija-at nija-at requested a review from a team May 20, 2020 11:47
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label May 20, 2020
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 38df483
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: f8519ab
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Contributor

@NetaNir NetaNir left a comment

Choose a reason for hiding this comment

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

I had one question, not blocking. Approving and marking as do-not-merge so you can review it

public addS3EventSelector(dataResourceValues: string[], options: AddEventSelectorOptions = {}) {
public addS3EventSelector(s3Selector: S3EventSelector[], options: AddEventSelectorOptions = {}) {
if (s3Selector.length === 0) { return; }
const dataResourceValues = s3Selector.map((sel) => `${sel.bucket.bucketArn}/${sel.objectPrefix ?? ''}`);
return this.addEventSelector(DataResourceType.S3_OBJECT, dataResourceValues, options);
Copy link
Contributor

Choose a reason for hiding this comment

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

If objectPrefix is empty is it ok for the / to be appended?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe so, yes.

From the documentation -

"To log data events for all objects in all S3 buckets in your AWS account, specify the prefix as arn:aws:s3:::.

To log data events for all objects in an S3 bucket, specify the bucket and an empty object prefix such as arn:aws:s3:::bucket-1/. The trail logs data events for all objects in this S3 bucket.

To log data events for specific objects, specify the S3 bucket and object prefix such as arn:aws:s3:::bucket-1/example-images. The trail logs data events for objects in this S3 bucket that match the prefix."

@NetaNir NetaNir added the pr/do-not-merge This PR should not be merged at this time. label May 27, 2020
@nija-at nija-at removed the pr/do-not-merge This PR should not be merged at this time. label May 27, 2020
@mergify
Copy link
Contributor

mergify bot commented May 27, 2020

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: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 242d93f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@mergify
Copy link
Contributor

mergify bot commented May 27, 2020

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 mergify bot merged commit 0028778 into master May 27, 2020
@mergify mergify bot deleted the nija-at/cloudtrail-bettereventselectors branch May 27, 2020 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants