-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deno failing with AWS SDK credentials with npm specifier #17666
Comments
Duplicate of #16810, let's continue there. |
@bartlomieju I don't think it is the same issue, this is related to credentials. I believe the behavior I reported is related to the following package that is not working with Deno as it is using node-bindings: |
Note that the issue with awslabs/aws-crt-nodejs is also why this aws-sdk deno port has been abandoned: |
@soundstep any chance you could try with latest Deno (v1.34.1) and let me know if the problem persists? We polyfilled a lot of missing APIs since you opened this issue and I expect it should just work these days. |
Yes, I'll try to check that when I get a chance! |
I can confirm that this works with deno #!/usr/bin/env -S deno run -A --reload
import { ListObjectsCommand, S3Client } from 'npm:@aws-sdk/[email protected]';
console.log('No AWS credentials setup');
const client = new S3Client({
region: Deno.env.get('AWS_REGION') || 'eu-west-1',
});
console.log('S3 client created, executing ListObjectsCommand');
try {
const res = await client.send(
new ListObjectsCommand({
Bucket: '<BUCKET_NAME>',
}),
);
console.log(res);
Deno.exit();
} catch (err) {
console.log(err);
Deno.exit(1);
} And this was already working with web identity credentials: import { ListObjectsCommand, S3Client } from 'npm:@aws-sdk/[email protected]';
const client = new S3Client({
region: Deno.env.get('AWS_REGION') || 'eu-west-1',
});
console.log('S3 client created, executing ListObjectsCommand');
try {
const res = await client.send(
new ListObjectsCommand({
Bucket: '<BUCKET_NAME>',
}),
);
console.log('response length:', res.Contents.length);
Deno.exit();
} catch (err) {
console.log(err);
Deno.exit(1);
} |
cross-posting another related issue that I came across with the aws sdk and R2 based on their docs for node usage https://developers.cloudflare.com/r2/reference/data-location: import * as s3 from 'npm:@aws-sdk/client-s3'
const s3_client = new s3.S3({
region: 'auto',
endpoint: R2_BASE_URL,
credentials: {
accessKeyId: ACCESS_KEY_ID,
secretAccessKey: ACCESS_KEY_SECRET,
}
})
const result = await s3_client.createMultipartUpload({
Bucket: 'MYBUCKET',
Key: `${Date.now()}`,
}) gives this error:
running the same snippet in node (with a few changes like removing the |
I think this might be related. The following script importing the S3 package from esh.sh and running on Deno 1.39.4 works... import { S3 } from "https://esm.sh/@aws-sdk/[email protected]"
Deno.serve(async (req) => {
const { name } = await req.json()
const config = {
region: Deno.env.get('AWS_REGION') ?? '',
credentials: {
accessKeyId: Deno.env.get('AWS_ACCESS_KEY_ID') ?? '',
secretAccessKey: Deno.env.get('AWS_SECRET_ACCESS_KEY') ?? '',
sessionToken: Deno.env.get('AWS_SESSION_TOKEN') ?? '',
}
}
console.log('start instantiating S3 client', config)
const s3 = new S3(config);
console.log('finish instantiating S3 client')
const data = {
message: `Hello ${name}!`,
}
return new Response(
JSON.stringify(data),
{ headers: { "Content-Type": "application/json" } },
)
}) However, if S3 is imported using the npm specifier... // import { S3 } from "https://esm.sh/@aws-sdk/[email protected]"
import { S3 } from "npm:@aws-sdk/[email protected]" ...then the following error occurs
The two import approaches are loading in different dependencies despite the same version being specified. Interestingly, the same code runs successfully outside of a Deno Deploy function running locally. |
fwiw, I moved over to a deno library for interacting with aws (well, R2 compatible apis in my case) https://deno.land/x/[email protected]. This repo isnt quite as maintained as the official npm sdk, but it works like a charm |
Any lights on this? |
Deno 2.1.9 contains a fix that for several AWS SDK, that was due to missing |
This is about using the AWS SDK V3 with Deno and the npm specifier:
The issue has reported there: aws/aws-sdk-js-v3#4405.
The import is working properly, but the usage does not.
Can provide help to debug this issue?
Thank you in advance.
The text was updated successfully, but these errors were encountered: