Closed drernie closed 9 months ago
Only used for
const s3 = new S3();
const data = await s3.getObject(params).promise();
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.
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;
}
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
The v2 SDK may also be the cause of:
...941ca3e8f2f10e159b39988705675222467f2fe8f01584654c6b10/index.js 22.0mb ⚠️
Or just use process.env.CDK_DEFAULT_REGION
else throw error
(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)