-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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): isOrganizationTrail attaches insufficient permissions to bucket #29242
Changes from all commits
54ed725
c414c46
352a8d0
9669565
e87a44d
c8ba648
8d88e17
d15f25e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,14 @@ export interface TrailProps { | |
*/ | ||
readonly isOrganizationTrail?: boolean; | ||
|
||
/** The orgId. | ||
* | ||
* Required when `isOrganizationTrail` is set to true to attach the necessary permissions. | ||
* | ||
* @default - No orgId | ||
*/ | ||
readonly orgId?: string; | ||
|
||
/** | ||
* A JSON string that contains the insight types you want to log on a trail. | ||
* | ||
|
@@ -262,6 +270,22 @@ export class Trail extends Resource { | |
}, | ||
})); | ||
|
||
if (props.isOrganizationTrail) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could also add a warning in the case that Warning could be something like this but any alternative suggestions are welcome: |
||
this.s3bucket.addToResourcePolicy(new iam.PolicyStatement({ | ||
resources: [this.s3bucket.arnForObjects( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the doc, it mentions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be this value for the resources:
|
||
`AWSLogs/${props.orgId}/*`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the below snippet, wouldn't the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a different permission from that one we are adding here:
|
||
)], | ||
actions: ['s3:PutObject'], | ||
principals: [cloudTrailPrincipal], | ||
conditions: { | ||
StringEquals: { | ||
's3:x-amz-acl': 'bucket-owner-full-control', | ||
'aws:SourceArn': `arn:${this.stack.partition}:cloudtrail:${this.s3bucket.stack.region}:${this.s3bucket.stack.account}:trail/${props.trailName}`, | ||
}, | ||
}, | ||
})); | ||
} | ||
|
||
this.topic = props.snsTopic; | ||
if (this.topic) { | ||
this.topic.grantPublish(cloudTrailPrincipal); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it call
orgId
? Reaching this link, it seems to beThe name of the folder where the log files are stored, including the bucket name, a prefix (if you specified one), and your AWS account ID
. So more like account id?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The missing permission is specified under this section for organization trails. Specifically the third policy in that section which requires the
o-organizationID
:Apologies, I just realized the link to the exact code block just redirects you to the top of the page which is a bit misleading.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes a lot more sense! Thanks!