Skip to content

Commit

Permalink
feat(frontend): Allow setting s3 region for artifacts (#6409)
Browse files Browse the repository at this point in the history
* feat(frontend): Allow setting AWS_S3_ENDPOINT

Allows setting the S3 endpoint used by minio to allow regions other than us-east-1

* feat(frontend): allow to configure s3 bucket region for artifacts

* fix formatting

* add integration test for non-default s3 bucket region
  • Loading branch information
neerfri authored Oct 31, 2021
1 parent 7fdba90 commit af51bd1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions frontend/server/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export function loadConfigs(argv: string[], env: ProcessEnv): UIConfigs {
/** minio client use these to retrieve s3 objects/artifacts */
AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY,
AWS_REGION,
/** http/https base URL */
HTTP_BASE_URL = '',
/** http/https fetch with this authorization header key (for example: 'Authorization') */
Expand Down Expand Up @@ -124,6 +125,7 @@ export function loadConfigs(argv: string[], env: ProcessEnv): UIConfigs {
aws: {
accessKey: AWS_ACCESS_KEY_ID || '',
endPoint: 's3.amazonaws.com',
region: AWS_REGION || 'us-east-1',
secretKey: AWS_SECRET_ACCESS_KEY || '',
},
http: {
Expand Down Expand Up @@ -201,6 +203,7 @@ export interface MinioConfigs {
}
export interface AWSConfigs {
endPoint: string;
region: string;
accessKey: string;
secretKey: string;
}
Expand Down
25 changes: 25 additions & 0 deletions frontend/server/integration-tests/artifact-get.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('/artifacts', () => {
expect(mockedMinioClient).toBeCalledWith({
accessKey: 'aws123',
endPoint: 's3.amazonaws.com',
region: 'us-east-1',
secretKey: 'awsSecret123',
});
done(err);
Expand All @@ -126,6 +127,30 @@ describe('/artifacts', () => {
expect(mockedMinioClient).toBeCalledWith({
accessKey: 'aws123',
endPoint: 's3.amazonaws.com',
region: 'us-east-1',
secretKey: 'awsSecret123',
});
done(err);
});
});

it('responds with a s3 artifact from bucket in non-default region if source=s3', done => {
const mockedMinioClient: jest.Mock = jest.spyOn(minioHelper, 'createMinioClient') as any;
const configs = loadConfigs(argv, {
AWS_ACCESS_KEY_ID: 'aws123',
AWS_SECRET_ACCESS_KEY: 'awsSecret123',
AWS_REGION: 'eu-central-1',
});
app = new UIServer(configs);

const request = requests(app.start());
request
.get('/artifacts/get?source=s3&bucket=ml-pipeline&key=hello%2Fworld.txt')
.expect(200, artifactContent, err => {
expect(mockedMinioClient).toBeCalledWith({
accessKey: 'aws123',
endPoint: 's3.amazonaws.com',
region: 'eu-central-1',
secretKey: 'awsSecret123',
});
done(err);
Expand Down

0 comments on commit af51bd1

Please sign in to comment.