-
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
feat(s3): server access logs #5072
Conversation
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
e2f87dc
to
7cc5e96
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
* @param logFilePrefix Optional log file prefix. | ||
*/ | ||
public enableServerAccessLogs(destinationBucket: IBucket, logFilePrefix?: string): void { | ||
(this.node.defaultChild as CfnBucket).loggingConfiguration = { |
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.
move this to Bucket
and don't use node.defaultChild
but rather directly reference the resource.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Missing unit tests to cover both usages (props and method)
@eladb yeap, I'll add the unit tests later today |
2bd9431
to
b07655a
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
2 similar comments
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
9c07f82
to
6a44bfa
Compare
6a44bfa
to
f4ea18c
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
sorry, but I think we need another round... Eventually we'll nail it :-)
happy to send you a PR with my proposal against your branch.
*/ | ||
public allowLogDelivery() { | ||
if (this.accessControl && this.accessControl !== BucketAccessControl.LOG_DELIVERY_WRITE) { | ||
throw new Error("The bucket's ACL has been set and can't be changed"); |
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.
throw new Error("The bucket's ACL has been set and can't be changed"); | |
throw new Error("Cannot enable log delivery to this bucket because the bucket's ACL has been set and can't be changed"); |
/** | ||
* Grants write permissions for the LogDelivery group to the bucket. | ||
*/ | ||
allowLogDelivery(): void; |
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.
I am still don't feel too good about this. The name is confusing, and users might think that this is how they can enable log delivery.
I am starting to think that maybe we should make this an internal API on Bucket
(instead of IBucket
). If people want to set the log delivery access control they can use the accessControl
property when they create the bucket.
export class Bucket ... {
/** @internal */
public _allowLogDelivery() { ... }
};
Then, in the consuming side, you will need to check if your IBucket
is a Bucket
. Otherwise, you won't be able to use it for log delivery because you can't set it's access control:
if (props.serverAccessLogsBucket instanceof Bucket) {
props.serverAccessLogsBucket._allowLogDelivery();
}
And that's it. I think it will simplify dramatically.
LMK if you want me to send you a PR with this proposal.
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.
Yea, sounds good. I moved the allowLogDelivery
to the Bucket class and set it as a private method. I'm not sure what would be the difference by using the @internal
annotation, tho.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Yes, looks better... I really like it that we can do this without extending the surface area.
A few additional minor comments
/** | ||
* Optional bucket Access Control. | ||
* | ||
* @default BucketAccessControl.PRIVATE | ||
*/ | ||
accessControl?: BucketAccessControl; | ||
|
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.
Remove this please
/** | ||
* Optional Bucket access control. | ||
*/ | ||
public abstract accessControl?: BucketAccessControl; | ||
|
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.
Remove this please
@@ -980,6 +1005,7 @@ export class Bucket extends BucketBase { | |||
|
|||
public readonly encryptionKey?: kms.IKey; | |||
public policy?: BucketPolicy; | |||
public accessControl?: BucketAccessControl; |
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.
Make this private
@@ -1358,6 +1405,14 @@ export class Bucket extends BucketBase { | |||
routingRules | |||
}; | |||
} | |||
|
|||
private allowLogDelivery() { |
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.
add docstring that explains what this is doing
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Please add a README entry
@@ -956,6 +968,7 @@ export class Bucket extends BucketBase { | |||
public readonly bucketWebsiteNewUrlFormat = newUrlFormat; | |||
public readonly encryptionKey = attrs.encryptionKey; | |||
public policy?: BucketPolicy = undefined; | |||
public accessControl?: BucketAccessControl = undefined; |
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.
public accessControl?: BucketAccessControl = undefined; |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Yaaas! Thanks for all your patience
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
@eladb thanks for all the learnings, really insightful :) really appreciate it! |
closes #5071
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license