More Related Content Similar to Introduction to Version 3 of the AWS SDK for JavaScript (TypeScript) (DEV379-R2) - AWS re:Invent 2018 (20) More from Amazon Web Services (20) Introduction to Version 3 of the AWS SDK for JavaScript (TypeScript) (DEV379-R2) - AWS re:Invent 20182. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Introduction to Version 3 of the
AWS SDK for JavaScript (TypeScript)
Christopher Radek
Software Development Engineer
Amazon Web Services/SDKs
D E V 3 7 9 - R
Trevor Rowe
Software Development Manager
Amazon Web Services/SDKs
3. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Key features of the v3 AWS SDK for JavaScript
TypeScript
Modularized
Middleware
Promise-based API
Client-specific configuration
Standalone signers
Consistent credential loading
4. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Improved dev experience with TypeScript
JavaScript with types
Code completion in editors
Ships as JavaScript
Types optional
function sayHello(name: string): void {
console.log(`Hello, ${name}!`);
}
sayHello('re:invent');
5. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
6. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Monolithic v2 SDK
clients xml
query utilities
aws-sdk
7. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Modularized v3 SDK
S3 DynamoDBLambdaEC2
Query JSONSigners RESTXML
8. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Size benefits of modularization
1720
222
101 55
246
65 20 16
0
200
400
600
800
1000
1200
1400
1600
1800
2000
v2 (full) v2 (single) v3 (client) v3 (command)
SDK size in KB
bundled gzipped
9. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
10. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Service packages are code-generated
Package
Generator
Models
Easier to debug
Better stack traces
Meaningful diffs
Easier to mock
11. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Promise-based
async function invoke() {
try {
const data = await lambda.invoke({
FunctionName: 'foo’
});
console.log(data.Payload);
} catch (err) {
console.error(err);
}
}
12. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Per-client configuration
const lambda = new Lambda({
region: 'us-west-2’,
credentials: {/* creds */},
maxRetries: 3
});
13. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Shares configuration with AWS CLI
# ~/.aws/config
[default]
aws_access_key_id=foo
aws_secret_access_key=bar
[profile dev]
aws_access_key_id=foo2
aws_secret_access_key=bar2
14. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Standalone Signature Version 4 Signers
const {SignatureV4} = require('@aws-sdk/signature-v4-node’);
async function sign() {
const signer = new SignatureV4({/* configuration */});
const signedRequest = await signer.sign({/* apiGatewayRequest */});
return signedRequest;
}
15. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
16. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.
Available on
GitHub
aws/aws-sdk-js-v3
18. © 2018, Amazon Web Services, Inc. or its affiliates. All rights reserved.