data-yaml / vivos

Versioned Interoperability to Velocitize Open Science
Apache License 2.0
0 stars 0 forks source link

chore: javascript sdkV3 #16

Closed drernie closed 9 months ago

drernie commented 9 months ago

(node:88992) NOTE: We are formalizing our plans to enter AWS SDK for JavaScript (v2) into maintenance mode in 2023.

Please migrate your code to use AWS SDK for JavaScript (v3). For more information, check the migration guide at https://a.co/7PzMCcy (Use node --trace-warnings ... to show where the warning was created)

drernie commented 9 months ago

Only used for

   const s3 = new S3();
    const data = await s3.getObject(params).promise();
drernie commented 9 months ago
    it('should getObject correctly', async () => {
      const bucket = 'quilt-example';
      const key = 'akarve/covid-directory/vega.json';
      const result = await Constants.getObject(bucket, key);
      expect(result).toBeDefined();
      expect(result).toHaveProperty('config');
    });

Fails with:

    PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
drernie commented 9 months ago

Probably because V3 requires a region for the explicit client:

  public static client(): S3Client {
    return new S3Client({ });
  }

  public static async getObject(bucket: string, key: string): Promise<any> {
    const command = new GetObjectCommand({
      Bucket: bucket,
      Key: key,
    });
    const client = Constants.client();
    const response = await client.send(command);
    const stringData = await response.Body!.transformToString();
    return stringData;
  }
drernie commented 9 months ago

This is annoying a lot of people, even though it is plausibly the right thing to do. One option is another query parameter on the URI, perhaps: bucket?region=us-west=2

drernie commented 9 months ago

The v2 SDK may also be the cause of:

...941ca3e8f2f10e159b39988705675222467f2fe8f01584654c6b10/index.js 22.0mb ⚠️

drernie commented 9 months ago

Or just use process.env.CDK_DEFAULT_REGION else throw error