Menu
AWS SDK for JavaScript
Developer Guide for SDK v2.202.0

Getting Started in Node.js


                                        Relationship between JavaScript environments, the SDK, and Lambda

This example consists of a Node.js package that:

  • Creates an Amazon Simple Storage Service (Amazon S3) service object.

  • Creates an Amazon S3 bucket.

  • Uploads an object to the created bucket.

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 https://github.com/awslabs/aws-nodejs-sample.git

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