AWS SDK for JavaScript
The AWS SDK for JavaScript, commonly known as aws-sdk, is an essential tool for developers aiming to interact seamlessly with Amazon Web Services (AWS) directly from their JavaScript applications. This powerful node module supports both browser-based and Node.js environments, making it highly versatile for a range of applications, from websites to server backends. The aws-sdk enables developers to access the full suite of AWS services, including but not limited to Amazon S3 for storage, Amazon EC2 for compute capacity, and Amazon DynamoDB for NoSQL database services. This integration simplifies the process of leveraging cloud technology in applications, enhancing scalability, reliability, and overall performance.
To start using the aws-sdk in your project, the first step is to run the command 'npm install aws-sdk'. This command installs the SDK into your project environment, allowing you to begin coding with access to AWS services immediately. The npm package for aws-sdk is regularly updated, ensuring developers have access to the latest features and security enhancements. By using npm install aws-sdk, you ensure that your application can securely and efficiently communicate with AWS services, providing a robust foundation for building feature-rich applications. Furthermore, the extensive documentation and active community support make integrating AWS services into your application more straightforward, helping to reduce development time and potential integration errors.
The aws-sdk package not only offers extensive API support for all AWS services but also includes features like automatic retries, buffering for streaming, and event notifications, which are crucial for building robust applications. These features are designed to help developers create efficient, fault-tolerant applications that can scale as user demand grows. With millions of downloads, the aws-sdk stands as a testament to its reliability and necessity in modern web development, particularly for those looking to leverage the expansive capabilities of cloud resources in their applications.
Core dependencies of this npm package and its dev dependencies.
buffer, events, ieee754, jmespath, querystring, sax, url, util, uuid, xml2js, @types/node, browserify, chai, codecov, coffeeify, coffeescript, cucumber, eslint, hash-test-vectors, insert-module-globals, istanbul, jasmine, jasmine-core, json-loader, karma, karma-chrome-launcher, karma-jasmine, mocha, repl.history, semver, typescript, uglify-js, webpack
A README file for the aws-sdk code repository. View Code
We announced the upcoming end-of-support for AWS SDK for JavaScript v2. We recommend that you migrate to AWS SDK for JavaScript v3. For dates, additional details, and information on how to migrate, please refer to the linked announcement.
The AWS SDK for JavaScript v3 is the latest and recommended version, which has been GA since December 2020. Here is why and how you should use AWS SDK for JavaScript v3. You can try our experimental migration scripts in aws-sdk-js-codemod to migrate your application from v2 to v3.
To get help with your migration, please follow our general guidelines to open an issue and choose guidance. To give feedback on and report issues in the v3 repo, please refer to Giving feedback and contributing.
Watch this README and the AWS Developer Tools Blog for updates and announcements regarding the maintenance plans and timelines.
A maintenance mode message may be emitted by this package on startup. To suppress this message, use an environment variable:
AWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE=1 node my_program.js
or a JavaScript setting as follows:
var SDK = require('aws-sdk');
require('aws-sdk/lib/maintenance_mode_message').suppress = true;
To use the SDK in the browser, simply add the following script tag to your HTML pages:
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1623.0.min.js"></script>
You can also build a custom browser SDK with your specified set of AWS services. This can allow you to reduce the SDK's size, specify different API versions of services, or use AWS services that don't currently support CORS if you are working in an environment that does not enforce CORS. To get started:
http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/building-sdk-for-browsers.html
The AWS SDK is also compatible with browserify.
For browser-based web, mobile and hybrid apps, you can use AWS Amplify Library which extends the AWS SDK and provides an easier and declarative interface.
The preferred way to install the AWS SDK for Node.js is to use the npm package manager for Node.js. Simply type the following into a terminal window:
npm install aws-sdk
To use the SDK in a react native project, first install the SDK using npm:
npm install aws-sdk
Then within your application, you can reference the react native compatible version of the SDK with the following:
var AWS = require('aws-sdk/dist/aws-sdk-react-native');
Alternatively, you can use AWS Amplify Library which extends AWS SDK and provides React Native UI components and CLI support to work with AWS services.
You can also use Bower to install the SDK by typing the following into a terminal window:
bower install aws-sdk-js
The AWS SDK for JavaScript bundles TypeScript definition files for use in TypeScript projects and to support tools that can read .d.ts
files.
Our goal is to keep these TypeScript definition files updated with each release for any public api.
Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets a few of these requirements:
Use latest version of TypeScript. We recommend 4.x+
Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window:
npm install --save-dev @types/node
If you are targeting at es5 or older ECMA standards, your tsconfig.json
has to include 'es5'
and 'es2015.promise'
under compilerOptions.lib
.
See tsconfig.json for an example.
To use the TypeScript definition files with the global AWS
object in a front-end project, add the following line to the top of your JavaScript file:
/// <reference types="aws-sdk" />
This will provide support for the global AWS
object.
To use the TypeScript definition files within a Node.js project, simply import aws-sdk
as you normally would.
In a TypeScript file:
// import entire SDK
import AWS from 'aws-sdk';
// import AWS object without services
import AWS from 'aws-sdk/global';
// import individual service
import S3 from 'aws-sdk/clients/s3';
NOTE: You need to add "esModuleInterop": true
to compilerOptions of your tsconfig.json
. If not possible, use like import * as AWS from 'aws-sdk'
.
In a JavaScript file:
// import entire SDK
var AWS = require('aws-sdk');
// import AWS object without services
var AWS = require('aws-sdk/global');
// import individual service
var S3 = require('aws-sdk/clients/s3');
To create React applications with AWS SDK, you can use AWS Amplify Library which provides React components and CLI support to work with AWS services.
Due to the SDK's reliance on node.js typings, you may encounter compilation issues when using the typings provided by the SDK in an Angular project created using the Angular CLI.
To resolve these issues, either add "types": ["node"]
to the project's tsconfig.app.json
file, or remove the "types"
field entirely.
AWS Amplify Library provides Angular components and CLI support to work with AWS services.
There are a few known limitations with the bundled TypeScript definitions at this time:
apiVersion
, regardless of which apiVersion
is specified when creating a client.any
type.The best way to interact with our team is through GitHub. You can open an issue and choose from one of our templates for bug reports, feature requests or guidance. You may also find help on community resources such as StackOverFlow with the tag #aws-sdk-js. If you have a support plan with AWS Support, you can also create a new support case.
Please make sure to check out our resources too before opening an issue:
Please see SERVICES.md for a list of supported services.
For information about maintenance and support for SDK major versions and their underlying dependencies, see the following in the AWS SDKs and Tools Shared Configuration and Credentials Reference Guide:
We welcome community contributions and pull requests. See CONTRIBUTING.md for information on how to set up a development environment and submit code.
This SDK is distributed under the Apache License, Version 2.0, see LICENSE.txt and NOTICE.txt for more information.