-
Notifications
You must be signed in to change notification settings - Fork 0
Support attachments in room requests updates + multiregion s3 for assets bucket #367
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
Changes from 12 commits
71bc0ed
0af7c04
dee9d82
69f8681
ad951ed
d15139a
70c92ef
b5e39c0
2966bcf
c83dc5b
4488971
f1dea79
1e9dfe2
fde201a
888ad92
c3f63b5
9d7ff31
604a826
0449677
d2789d9
c32847f
feaab0b
6b64c35
8507369
6399b67
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 |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { PutObjectCommand, type S3Client } from "@aws-sdk/client-s3"; | ||
| import { getSignedUrl } from "@aws-sdk/s3-request-presigner"; | ||
| import { InternalServerError } from "common/errors/index.js"; | ||
|
|
||
| export type CreatePresignedPutInputs = { | ||
| s3client: S3Client; | ||
| bucketName: string; | ||
| key: string; | ||
| length: number; | ||
| mimeType: string; | ||
| md5hash: string; // Must be a base64-encoded MD5 hash | ||
| urlExpiresIn?: number; | ||
| }; | ||
|
|
||
| export async function createPresignedPut({ | ||
| s3client, | ||
| bucketName, | ||
| key, | ||
| length, | ||
| mimeType, | ||
| md5hash, | ||
| urlExpiresIn, | ||
| }: CreatePresignedPutInputs) { | ||
| const command = new PutObjectCommand({ | ||
| Bucket: bucketName, | ||
| Key: key, | ||
| ContentLength: length, | ||
| ContentType: mimeType, | ||
| ContentMD5: md5hash, | ||
| }); | ||
|
|
||
| const expiresIn = urlExpiresIn || 900; | ||
|
|
||
| try { | ||
| return await getSignedUrl(s3client, command, { expiresIn }); | ||
| } catch (err) { | ||
| throw new InternalServerError({ | ||
| message: "Could not create S3 upload presigned url.", | ||
| }); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,6 +33,7 @@ export type ConfigType = { | |||||||||||||
| OrgAdminGithubParentTeam: number; | ||||||||||||||
| GithubIdpSyncEnabled: boolean | ||||||||||||||
| GithubOrgId: number; | ||||||||||||||
| AssetsBucketId: string; | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| export type GenericConfigType = { | ||||||||||||||
|
|
@@ -142,7 +143,8 @@ const environmentConfig: EnvironmentConfigType = { | |||||||||||||
| GithubOrgName: "acm-uiuc-testing", | ||||||||||||||
| GithubOrgId: 235748315, | ||||||||||||||
| OrgAdminGithubParentTeam: 14420860, | ||||||||||||||
| GithubIdpSyncEnabled: false | ||||||||||||||
| GithubIdpSyncEnabled: false, | ||||||||||||||
| AssetsBucketId: `427040638965-infra-core-api-assets-${genericConfig.AwsRegion}` | ||||||||||||||
| }, | ||||||||||||||
|
Comment on lines
+146
to
148
Contributor
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. Fix Prettier-required trailing comma. Prettier fails on this object because the new - AssetsBucketId: `427040638965-infra-core-api-assets-${genericConfig.AwsRegion}`
+ AssetsBucketId: `427040638965-infra-core-api-assets-${genericConfig.AwsRegion}`,📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 147-147: Insert (prettier/prettier) 🤖 Prompt for AI Agents |
||||||||||||||
| prod: { | ||||||||||||||
| UserFacingUrl: "https://core.acm.illinois.edu", | ||||||||||||||
|
|
@@ -174,7 +176,8 @@ const environmentConfig: EnvironmentConfigType = { | |||||||||||||
| GithubOrgName: "acm-uiuc", | ||||||||||||||
| GithubOrgId: 425738, | ||||||||||||||
| OrgAdminGithubParentTeam: 12025214, | ||||||||||||||
| GithubIdpSyncEnabled: true | ||||||||||||||
| GithubIdpSyncEnabled: true, | ||||||||||||||
| AssetsBucketId: `298118738376-infra-core-api-assets-${genericConfig.AwsRegion}` | ||||||||||||||
| }, | ||||||||||||||
devksingh4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| export const STRIPE_LINK_RETENTION_DAYS = 90; // this number of days after the link is deactivated. | ||
| export const AUDIT_LOG_RETENTION_DAYS = 365; | ||
| export const ROOM_RESERVATION_RETENTION_DAYS = 730; | ||
| export const FULFILLED_PURCHASES_RETENTION_DAYS = 730; // ticketing/merch: after the purchase is marked as fulfilled. | ||
| export const ROOM_RESERVATION_RETENTION_DAYS = 1460; | ||
| export const FULFILLED_PURCHASES_RETENTION_DAYS = 1460; // ticketing/merch: after the purchase is marked as fulfilled. | ||
| export const EVENTS_EXPIRY_AFTER_LAST_OCCURRENCE_DAYS = 1460; // hold events for 4 years after last occurrence | ||
| // we keep data longer for historical analytics purposes | ||
| // we keep data longer for historical analytics purposes in S3 as needed |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| data "aws_caller_identity" "current" {} | ||
| data "aws_region" "current" {} | ||
|
|
||
| locals { | ||
| asset_bucket_prefix = "${data.aws_caller_identity.current.account_id}-${var.ProjectId}-assets" | ||
| } | ||
|
|
||
| module "buckets" { | ||
| source = "git::https://github.com/acm-uiuc/terraform-modules.git//multiregion-s3?ref=v2.0.0" | ||
| Region1 = var.PrimaryRegion | ||
| Region2 = var.SecondaryRegion | ||
| BucketPrefix = local.asset_bucket_prefix | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_lifecycle_configuration" "expire_noncurrent" { | ||
| for_each = module.buckets.buckets_info | ||
| region = each.key | ||
devksingh4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| bucket = each.value.id | ||
|
|
||
| rule { | ||
| id = "expire-noncurrent-versions" | ||
| status = "Enabled" | ||
|
|
||
| noncurrent_version_expiration { | ||
| noncurrent_days = 3 | ||
| } | ||
| } | ||
|
|
||
| rule { | ||
| id = "expire-delete-markers" | ||
| status = "Enabled" | ||
|
|
||
| expiration { | ||
| expired_object_delete_marker = true | ||
| } | ||
| } | ||
|
|
||
| rule { | ||
| id = "abort-incomplete-multipart" | ||
| status = "Enabled" | ||
|
|
||
| abort_incomplete_multipart_upload { | ||
| days_after_initiation = 3 | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_intelligent_tiering_configuration" "tiering" { | ||
| for_each = module.buckets.buckets_info | ||
| bucket = each.value.id | ||
| region = each.key | ||
| name = "EntireBucketIntelligentTiering" | ||
|
|
||
| tiering { | ||
| access_tier = "ARCHIVE_ACCESS" | ||
| days = 90 | ||
| } | ||
| } | ||
|
|
||
| resource "aws_s3_bucket_cors_configuration" "ui_uploads" { | ||
| for_each = module.buckets.buckets_info | ||
| bucket = each.value.id | ||
| region = each.key | ||
| cors_rule { | ||
| allowed_headers = ["*"] | ||
| allowed_methods = ["GET", "PUT"] | ||
| allowed_origins = var.BucketAllowedCorsOrigins | ||
| expose_headers = ["ETag"] | ||
| max_age_seconds = 3000 | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| variable "PrimaryRegion" { | ||
| type = string | ||
| default = "us-east-2" | ||
| } | ||
|
|
||
| variable "SecondaryRegion" { | ||
| type = string | ||
| default = "us-west-2" | ||
| } | ||
|
|
||
| variable "ProjectId" { | ||
| type = string | ||
| description = "Prefix before each resource" | ||
| } | ||
devksingh4 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| variable "BucketAllowedCorsOrigins" { | ||
| type = list(string) | ||
| description = "List of URLs that bucket can be read/written from." | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.