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 a195468 commit 6b4788f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/update-prod-curator-db-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Migrate prod database schema
on:
push:
# Run workflow when the schema changes. The branch name should always reflect the current release!
branches: [1.9-stable]
branches: [1.11-stable]
paths:
- "data-serving/scripts/setup-db/migrations/**"
- ".github/workflows/update-prod-curator-db-schema.yaml"
workflow_dispatch:
# Run workflow when the schema changes. The branch name should always reflect the current release!
branches: [1.9-stable]
branches: [1.11-stable]
paths:
- "data-serving/scripts/setup-db/migrations/**"
- ".github/workflows/update-prod-curator-db-schema.yaml"
Expand Down
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 6b4788f

Please sign in to comment.