Skip to content

Commit

Permalink
Making data bucket an env var
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-sheldon committed Apr 26, 2022
1 parent c4a0d50 commit 6756104
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 5 additions & 3 deletions verification/curator-service/api/src/controllers/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const defaultOutputQuery =
export default class CasesController {
constructor(
private readonly dataServerURL: string,
private readonly completeDataBucket: string,
private readonly countryDataBucket: string,
private readonly s3Client: AWS.S3,
) {}

Expand Down Expand Up @@ -200,7 +202,7 @@ export default class CasesController {
const filename = `gh_${year}-${month}-${day}.tar`;

const params = {
Bucket: 'covid-19-data-export',
Bucket: this.completeDataBucket,
Key: 'latest/latestdata-csv.tar',
Expires: 5 * 60,
ResponseContentDisposition:
Expand Down Expand Up @@ -248,7 +250,7 @@ export default class CasesController {
const filename = `${country}.${format}.gz`;
const filepath = `${format}/${filename}`;
const params = {
Bucket: 'covid-19-country-export',
Bucket: this.countryDataBucket,
Key: filepath,
Expires: 5 * 60,
ResponseContentDisposition:
Expand Down Expand Up @@ -305,7 +307,7 @@ export default class CasesController {
const filepath = `${format}/${country}.${format}.gz`;
const contains = await this.s3Client
.headObject({
Bucket: 'covid-19-country-export',
Bucket: this.countryDataBucket,
Key: filepath,
})
.promise()
Expand Down
6 changes: 5 additions & 1 deletion verification/curator-service/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,11 @@ async function makeApp() {
);

// Configure cases controller proxying to data service.
const casesController = new CasesController(env.DATASERVER_URL, s3Client);
const casesController = new CasesController(
env.DATASERVER_URL,
env.COMPLETE_DATA_BUCKET,
env.COUNTRY_DATA_BUCKET,
s3Client);
apiRouter.get(
'/cases',
authenticateByAPIKey,
Expand Down
10 changes: 10 additions & 0 deletions verification/curator-service/api/src/util/validate-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export default function validateEnv(): Readonly<{
AWS_ACCESS_KEY_ID: string;
AWS_SECRET_ACCESS_KEY: string;
AWS_SERVICE_REGION: string;
COMPLETE_DATA_BUCKET: string;
COUNTRY_DATA_BUCKET: string;
CURATOR_VERSION: string;
DATASERVER_URL: string;
DB_CONNECTION_STRING: string;
Expand Down Expand Up @@ -44,6 +46,14 @@ export default function validateEnv(): Readonly<{
desc: 'AWS region in which to interact with services/resources',
default: 'eu-central-1',
}),
COMPLETE_DATA_BUCKET: str({
desc: 'S3 bucket containing case data by country',
devDefault: 'covid-19-data-export-dev-eu',
}),
COUNTRY_DATA_BUCKET: str({
desc: 'S3 bucket containing case data by country',
devDefault: 'covid-19-country-export-dev-eu',
}),
CURATOR_VERSION: str({
desc: 'version string to display in UI for bug reports etc.',
devDefault: '(local testing)',
Expand Down

0 comments on commit 6756104

Please sign in to comment.