does anyone know how to configure logging configur...
# help
a
does anyone know how to configure logging configurations for an s3 bucket in the sst.Bucket instance in SST ?
s
you want the
serverAccessLogsBucket
and
serverAccessLogsPrefix
properties
just note, though, if your bucket is behind a CloudFront distribution, you may want to log the CloudFront distribution, NOT the bucket
a
Oh perfect, thank you a lot, I was looking for something like DestinationBucket and LogFilePrefix because I am coming from sls so thanks a lot found it in the cdk documentation now 🙌
f
Yup, elaborating on @Sam Hulick’s suggestion:
Copy code
const logBucket = new sst.Bucket(this, "AccessLogBucket");

const bucket = new sst.Bucket(this, 'MyBucket', {
  s3Bucket: {
    serverAccessLogsBucket: accessLogsBucket.s3Bucket,
    serverAccessLogsPrefix: 'logs',
  },
});
s
the reason I mention CloudFront is that the S3 logs won’t reflect actual file access since CF will be caching files. I started with S3 logs and then said “wait a minute.. this won’t tell me how much bandwidth a user is using” 😄
a
My bucket is not behind a CloudFront so it should be fine for now, thanks a lot I will keep this in mind for the future