-
Notifications
You must be signed in to change notification settings - Fork 4k
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): Invalid resource for policy when using sendToCloudWatchLogs #1851
Changes from 1 commit
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 |
---|---|---|
|
@@ -149,14 +149,13 @@ export class CloudTrail extends cdk.Construct { | |
}); | ||
this.cloudWatchLogsGroupArn = logGroup.logGroupArn; | ||
|
||
const logsRole = new iam.Role(this, 'LogsRole', {assumedBy: new iam.ServicePrincipal(cloudTrailPrincipal) }); | ||
const logsRole = new iam.Role(this, 'LogsRole', { assumedBy: new iam.ServicePrincipal(cloudTrailPrincipal) }); | ||
this.cloudWatchLogsRoleArn = logsRole.roleArn; | ||
|
||
const streamArn = `${this.cloudWatchLogsRoleArn}:log-stream:*`; | ||
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. Wait why was this not a static analysis error? 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. The field is |
||
logsRole.addToPolicy(new iam.PolicyStatement() | ||
.addActions("logs:PutLogEvents", "logs:CreateLogStream") | ||
.addResource(streamArn)); | ||
this.cloudWatchLogsRoleArn = logsRole.roleArn; | ||
|
||
} | ||
if (props.managementEvents) { | ||
const managementEvent = { | ||
|
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 is
cloudWatchLogsArn
optional?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.
Because it is meaningless if you do not enable output in CloudWatch Logs.