Skip to content

Commit

Permalink
feat(virus-scanner): allow endpoint to be specified (#7114)
Browse files Browse the repository at this point in the history
For environments that are neither AWS nor local dev, the virus scanner
lambda might be hosted elsewhere, eg, on a host running an emulated
environment. Grant the flexibility to specify the endpoint address to
reach the virus scanner, and thus the discretion to use AWS or some
other environment.
  • Loading branch information
LoneRifle authored Mar 1, 2024
1 parent da55f39 commit e0d6ac4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/app/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,16 @@ const s3 = new aws.S3({
// using aws-sdk v3 (FRM-993)
const virusScannerLambda = new Lambda({
region: basicVars.awsConfig.region,
// Endpoint is set for development mode to point to the separate docker container running the lambda function.
// For dev mode or where specified, endpoint is set to point to the separate docker container running the lambda function.
// host.docker.internal is a special DNS name which resolves to the internal IP address used by the host.
// Reference: https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
...(isDev ? { endpoint: 'http://host.docker.internal:9999' } : undefined),
...(isDev || basicVars.awsConfig.virusScannerLambdaEndpoint
? {
endpoint:
basicVars.awsConfig.virusScannerLambdaEndpoint ||
'http://host.docker.internal:9999',
}
: undefined),
})

const awsConfig: AwsConfig = {
Expand Down
6 changes: 6 additions & 0 deletions src/app/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ export const optionalVarsSchema: Schema<IOptionalVarsSchema> = {
default: '',
env: 'VIRUS_SCANNER_LAMBDA_FUNCTION_NAME',
},
virusScannerLambdaEndpoint: {
doc: 'Endpoint address for virus scanner lambda function. Specify this if the lambda is hosted neither on AWS nor your local dev environment.',
format: String,
default: '',
env: 'VIRUS_SCANNER_LAMBDA_ENDPOINT',
},
},
core: {
port: {
Expand Down
1 change: 1 addition & 0 deletions src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export interface IOptionalVarsSchema {
region: string
customCloudWatchGroup: string
virusScannerLambdaFunctionName: string
virusScannerLambdaEndpoint: string
}
mail: {
from: string
Expand Down

0 comments on commit e0d6ac4

Please sign in to comment.