aws-cdk icon indicating copy to clipboard operation
aws-cdk copied to clipboard

fix(cloudtrail): emit error if trailName is not set for organization trail

Open sarisia opened this issue 1 year ago • 4 comments

This PR is based on #30490 and I'll rebase this once it is merged

Issue # (if applicable)

no open issue

Reason for this change

Organization trail without trailName attaches improper s3 bucket policy which allows trail name undefined to send logs.

                        {
                            "Action": "s3:PutObject",
                            "Condition": {
                                "StringEquals": {
                                    "s3:x-amz-acl": "bucket-owner-full-control",
                                    "aws:SourceArn": {
                                        "Fn::Join": [
                                            "",
                                            [
                                                "arn:",
                                                {
                                                    "Ref": "AWS::Partition"
                                                },
                                                ":cloudtrail:us-east-1:123456789012:trail/undefined"
                                            ]
                                        ]
                                    }
                                }
                            },
                            "Effect": "Allow",
                            "Principal": {
                                "Service": "cloudtrail.amazonaws.com"
                            },
                            "Resource": {
                                "Fn::Join": [
                                    "",
                                    [
                                        {
                                            "Fn::GetAtt": [
                                                "TrailS30071F172",
                                                "Arn"
                                            ]
                                        },
                                        "/AWSLogs/o-xxxxxxxxx/*"
                                    ]
                                ]
                            }
                        }

Description of changes

  • make trailName required if isOrganizationTrail is set

Description of how you validated changes

  • Added unit test

Checklist


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

sarisia avatar Jun 07 '24 20:06 sarisia

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 09ce4b7c853ef28f57bd4a1608b49927becfd267
  • Result: FAILED
  • Build Logs (available for 30 days)

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

aws-cdk-automation avatar Jun 07 '24 20:06 aws-cdk-automation

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

aws-cdk-automation avatar Jun 29 '24 00:06 aws-cdk-automation

Could someone please review #30490 first? Thanks

sarisia avatar Jun 29 '24 06:06 sarisia

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.

aws-cdk-automation avatar Jul 07 '24 00:07 aws-cdk-automation

The pull request linter fails with the following errors:

❌ Fixes must contain a change to an integration test file and the resulting snapshot.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

aws-cdk-automation avatar Jul 07 '24 00:07 aws-cdk-automation