Skip to content

Commit

Permalink
Merge pull request #2 from non-97/feature/log-analytics
Browse files Browse the repository at this point in the history
🐛 S3サーバーアクセスログを任意のプレフィックスで出力できるように修正
  • Loading branch information
non-97 authored Apr 2, 2024
2 parents 26513fe + 092a0cb commit 0028181
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/construct/bucket-construct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export class BucketConstruct extends Construct {
autoDeleteObjects: props?.allowDeleteBucketAndObjects ? true : undefined,
accessControl: props?.accessControl,
serverAccessLogsBucket: props?.s3ServerAccessLogBucketConstruct?.bucket,
serverAccessLogsPrefix: props?.logFilePrefix,
serverAccessLogsPrefix:
props?.s3ServerAccessLogBucketConstruct?.bucket && props?.logFilePrefix
? `${props?.logFilePrefix}/`
: undefined,
});

props?.lifecycleRules?.forEach((lifecycleRule) => {
Expand Down
3 changes: 3 additions & 0 deletions lib/website-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class WebsiteStack extends cdk.Stack {

// Bucket for S3 Server Access Log
const s3serverAccessLogBucketConstruct = props.s3ServerAccessLog
?.enableAccessLog
? new BucketConstruct(this, "S3ServerAccessLogBucketConstruct", {
allowDeleteBucketAndObjects: props.allowDeleteBucketAndObjects,
accessControl: cdk.aws_s3.BucketAccessControl.LOG_DELIVERY_WRITE,
Expand All @@ -39,6 +40,7 @@ export class WebsiteStack extends cdk.Stack {

// Bucket for CloudFront Access Log
const cloudFrontAccessLogBucketConstruct = props.cloudFrontAccessLog
?.enableAccessLog
? new BucketConstruct(this, "CloudFrontAccessLogBucketConstruct", {
allowDeleteBucketAndObjects: props.allowDeleteBucketAndObjects,
accessControl: cdk.aws_s3.BucketAccessControl.LOG_DELIVERY_WRITE,
Expand All @@ -53,6 +55,7 @@ export class WebsiteStack extends cdk.Stack {
{
s3ServerAccessLogBucketConstruct: s3serverAccessLogBucketConstruct,
allowDeleteBucketAndObjects: props.allowDeleteBucketAndObjects,
logFilePrefix: props.s3ServerAccessLog?.logFilePrefix,
}
);

Expand Down

0 comments on commit 0028181

Please sign in to comment.