Skip to content
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

Make bucket public #719

Merged
merged 2 commits into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion apps/infra/src/core/s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const bucketName = bucket.bucket
export const publicBucket = new aws.s3.BucketV2(
'publicLatitudeBucketResource',
{
acl: 'private', // Only allowing access through signed urls
acl: 'private', // Keep ACL private to disallow all actions by default
bucket: 'latitude-llm-public-bucket-production',
tags: {
Name: 'Latitude LLM public bucket',
Expand All @@ -33,3 +33,51 @@ export const publicBucket = new aws.s3.BucketV2(
)

export const publicBucketName = publicBucket.bucket

new aws.s3.BucketPolicy(
'publicLatitudeBucketPolicy',
{
bucket: publicBucket.id,
policy: publicBucket.arn.apply((bucketArn) =>
JSON.stringify({
Version: '2012-10-17',
Statement: [
{
Sid: 'PublicReadGetObject',
Effect: 'Allow',
Principal: '*',
Action: 's3:GetObject', // Note: all actions are disallowed by default
Resource: `${bucketArn}/*`,
},
],
}),
),
},
{ provider: regionProvider },
)

new aws.s3.BucketCorsConfigurationV2(
'publicLatitudeBucketCors',
{
bucket: publicBucket.id,
corsRules: [
{
allowedHeaders: ['*'],
allowedMethods: ['GET', 'HEAD'],
allowedOrigins: ['https://latitude.so', 'https://*.latitude.so'],
exposeHeaders: [
'ETag',
'Content-Type',
'Content-Length',
'Content-Range',
'Content-Disposition',
'Cache-Control',
'Last-Modified',
'Expires',
],
maxAgeSeconds: 24 * 3600, // 24 hours
},
],
},
{ provider: regionProvider },
)
Loading