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

fix(cloudtrail): Trail fails during resource creation due to invalid template properties when management events are 'None' #16387

Closed

Conversation

4naesthetic
Copy link
Contributor

Closes #15488.

Have done as much as I could to preserve backwards compatibility through this fix. It implements different behaviour than what was originally written which I would appreciate feedback on. The new implementation defaults to adding includeManagementEvents: false to event selectors when the Trail is constructed with managementEvents: ReadWriteType.NONE.

Although this is a contribution to a stable module, I consider this change to not have breaking changes as the original implementation generates CloudFormation that would result in stack deployment failure.


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

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: 2d5ac43
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@4naesthetic 4naesthetic changed the title fix(cloudtrail): CloudTrail synthesis when management events are 'None' fix(cloudtrail): Trail fails during resource creation due to invalid template properties when management events are 'None' Sep 30, 2021
@peterwoodworth peterwoodworth changed the title fix(cloudtrail): Trail fails during resource creation due to invalid template properties when management events are 'None' fix(cloudtrail): Trail fails during resource creation due to invalid template properties when management events are 'None' Oct 21, 2021
@github-actions github-actions bot added the @aws-cdk/aws-cloudtrail Related to AWS CloudTrail label Oct 21, 2021
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

I like what you're doing, but I think it's generally simpler to just do the following:

  • If includeManagementEvents needs to be true, add an event selector just for the management events.
  • For all subsequent event selectors that are added, unconditionally set includeManagementEvents: false.

From what I'm reading here, this should have the exact same effect and is much easier to understand. Wdyt?

@rix0rrr rix0rrr added bug This issue is a bug. p1 and removed @aws-cdk/aws-cloudtrail Related to AWS CloudTrail labels Mar 4, 2022
@aws-cdk-automation
Copy link
Collaborator

This PR has been in CHANGES REQUESTED for 21 days, and looks abandoned. It will be closed in 10 days if no further commits are pushed to it.

@github-actions
Copy link

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@github-actions github-actions bot added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Apr 20, 2022
@github-actions github-actions bot closed this Apr 20, 2022
mergify bot pushed a commit that referenced this pull request Jan 12, 2023
…template properties when management events are 'None' (#23569)

#### Overview 

Currently CDK produces invalid CloudFormation that fails validation by the CloudTrail API upon deployment when setting the `managementEvents` parameter to `ReadWriteType.NONE`.

Although this is a contribution to a stable module, I consider this change to not have breaking changes as the original implementation generates CloudFormation that would result in stack deployment failure so is currently broken.

#### Behaviour changes

*Setting `managementEvents` to `ReadWriteType.NONE`*

**Old behaviour:** Successfully synthesises but produces CloudFormation that fails to deploy.
**New behaviour:** Fails synthesis with a validation error if no additional event selectors are added to the trail, as the default behaviour of CloudTrail is to enable management events if no event selectors are provided. Sets `includeManagementEvents` to `false` by default when new event selectors are added unless overridden explicitly by the user.

#### Other options considered

The previous PR had a suggestion to just always set `includeManagementEvents` to `false` when adding additional event selectors rather than only setting it to `false` when the Trail was created with `ReadWriteType.NONE`. However, this would break backwards compatibility for some scenarios (such as where users don't set `managementEvents` when creating the trail and later add an event selector, as well as a bunch of other esoteric edge cases).

#### Related

Previous PR that was closed for staleness (#16387).

Closes #15488

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [X] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [X] 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
bug This issue is a bug. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. p1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(aws-cloudtrail): incorrect Trail synthesis when management_events is False
4 participants