There are a few differences between the packages @aws-sdk/client-sqs
and aws-sdk/clients/sqs
in terms of declaration, but what about the functionalities? Is there a single implication choosing any of them?
Using @aws-sdk/client-sqs
:
import { SQSClient, ListQueuesCommand } from '@aws-sdk/client-sqs';
export default class SQSHelper {
client: SQSClient;
constructor(region: string) {
this.client = new SQSClient({ region });
}
listQueues() {
return new Promise((resolve, reject) => {
this.client.send(new ListQueuesCommand({}), (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
}
);
}
}
Using aws-sdk/clients/sqs
:
import SQSClient from 'aws-sdk/clients/sqs';
export default class SQSHelper {
client: SQSClient;
constructor(region: string) {
this.client = new SQSClient({ region });
}
listQueues() {
return new Promise((resolve, reject) => {
this.client.listQueues({}, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
});
}
);
}
}
CodePudding user response:
SDK v3 versus v2. @aws-sdk/client-sqs
is part of AWS SDK for JavaScript v3. Client packages are modular in v3, which is now in GA. aws-sdk/clients/sqs
is from v2, which included all clients in one big package.
CodePudding user response:
@aws-sdk/client-sqs
is part of version 3 of AWS JavaScript SDK. aws-sdk/clients/sqs
is part of V2 JavaScript SDK.
As of today, you can use V2 SDK in Lambda without adding any additional dependencies to your Lambda package or without creating a new Lambda Layer. Most likely, this kind of support will happen for V3 in the future.