diff --git a/api/src/lib/aws.ts b/api/src/lib/aws.ts index c8db7cad..b802dc3c 100644 --- a/api/src/lib/aws.ts +++ b/api/src/lib/aws.ts @@ -15,7 +15,7 @@ import { getSignedUrl as awsGetSignedUrl } from '@aws-sdk/s3-request-presigner' import { StreamingBlobPayloadInputTypes } from '@smithy/types' import { QueryResolvers, CreateUploadInput } from 'types/graphql' -const CPF_REPORTER_BUCKET_NAME = `cpf-reporter-${process.env.environment}` +const REPORTING_DATA_BUCKET_NAME = `${process.env.REPORTING_DATA_BUCKET_NAME}` function getS3Client() { let s3: S3Client @@ -64,8 +64,8 @@ export function uploadWorkbook( uploadId: number, body: StreamingBlobPayloadInputTypes ) { - const folderName = `${upload.organizationId}/${upload.agencyId}/${upload.reportingPeriodId}/uploads/${upload.expenditureCategoryId}/${uploadId}/${upload.filename}` - return sendPutObjectToS3Bucket(CPF_REPORTER_BUCKET_NAME, folderName, body) + const folderName = `uploads/${upload.organizationId}/${upload.agencyId}/${upload.reportingPeriodId}/${upload.expenditureCategoryId}/${uploadId}/${upload.filename}` + return sendPutObjectToS3Bucket(REPORTING_DATA_BUCKET_NAME, folderName, body) } async function sendPutObjectToS3Bucket( @@ -85,7 +85,7 @@ async function sendPutObjectToS3Bucket( export function getTemplateRules(inputTemplateId: number) { return sendHeadObjectToS3Bucket( - CPF_REPORTER_BUCKET_NAME, + REPORTING_DATA_BUCKET_NAME, `templates/input_templates/${inputTemplateId}/rules/` ) } @@ -104,9 +104,9 @@ export async function s3PutSignedUrl( uploadId: number ): Promise { const s3 = getS3Client() - const key = `${upload.organizationId}/${upload.agencyId}/${upload.reportingPeriodId}/uploads/${upload.expenditureCategoryId}/${uploadId}/${upload.filename}` + const key = `uploads/${upload.organizationId}/${upload.agencyId}/${upload.reportingPeriodId}/${upload.expenditureCategoryId}/${uploadId}/${upload.filename}` const baseParams: PutObjectCommandInput = { - Bucket: CPF_REPORTER_BUCKET_NAME, + Bucket: REPORTING_DATA_BUCKET_NAME, Key: key, ContentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', diff --git a/terraform/functions.tf b/terraform/functions.tf index cc7fc194..60449690 100644 --- a/terraform/functions.tf +++ b/terraform/functions.tf @@ -47,8 +47,9 @@ locals { var.datadog_default_environment_variables, ), { - LOG_LEVEL = var.lambda_log_level - TZ = "UTC" + LOG_LEVEL = var.lambda_log_level + REPORTING_DATA_BUCKET_NAME = module.reporting_data_bucket.bucket_id + TZ = "UTC" }, ) lambda_default_execution_policies = compact([