AWS SDK for JavaScript
Developer Guide for SDK v2.211.0

Getting Started in Node.js

JavaScript code example that applies to Node.js execution

This Node.js code example shows:

  • How to create an Amazon Simple Storage Service (Amazon S3) service object.

  • How to create an Amazon S3 bucket.

  • How to upload an object to the created bucket.

Prerequisite Tasks

To set up and run this example, you must first complete these tasks:

For more information on installing Node.js packages, see How to Install Local Packages and How to Create Node.js Modules at the npm (the Node.js package manager) website. For information about downloading and installing the AWS SDK for JavaScript, see Installing the SDK for JavaScript.

Step 1: Downloading the Sample Project

You can download the sample package from GitHub with the following command. You must have Git installed.

git clone

Step 2: Installing the SDK and Dependencies

You install the SDK for JavaScript package using the npm (the Node.js package manager). From the aws-nodejs-sample directory in the package, type the following at the command line.

npm install

Step 3: Configuring the Access Keys

You need to provide credentials to AWS so only your account and its resources are accessed by the SDK. For more information about obtaining your account credentials, see Getting Your Credentials.

We recommend you create a shared credentials file to hold this information. For more information about how to create a shared credentials file, see Loading Credentials in Node.js from the Shared Credentials File. Your credentials file should resemble the following example.

[default] aws_access_key_id = YOUR_ACCESS_KEY_ID aws_secret_access_key = YOUR_SECRET_ACCESS_KEY

Step 4: Running the Sample

Type the following command to run the sample.

node sample.js