EasyManuals Logo

Amazon AWS SDK User Manual

Amazon AWS SDK
19 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #9 background imageLoading...
Page #9 background image
Credentials are the most important thing you need to set when using any AWS SDK. Credentials can be
set globally on the AWS.config object or per service by passing the credential information to the service
object directly.
There are a few ways to load credentials. Here they are, in order of recommendation:
1. Loaded from environment variables,
2. Loaded from a JSON file on disk,
3. Loaded from EC2 metadata service,
4. Hardcoded in your application
We recommend you not hard-code your AWS credentials in your application; however, it is reasonable
to temporarily hard-code credential information in small personal scripts or for testing purposes.
Credentials from Environment Variables
By default, the AWS SDK for Node.js will automatically detect AWS credentials set in your environment
and use them for requests.This means that if you properly set your environment variables, you do not
need to manage credentials in your application at all.
The keys that the SDK looks for are as follows:
AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN (optional)
Alternately, the SDK can accept the AMAZON_ prefix instead:
AMAZON_ACCESS_KEY_ID, AMAZON_SECRET_ACCESS_KEY, AMAZON_SESSION_TOKEN (optional)
Credentials from Disk
You can also load configuration and credentials from disk using AWS.config.loadFromPath by passing
a file to a JSON document containing the configuration data. For example, if you had a file named
'config.json' with the contents:
{ "accessKeyId": "akid", "secretAccessKey": "secret", "region": "us-east-1" }
You can load the JSON data using the command:
AWS.config.loadFromPath('./config.json');
Note that the loadFromPath method clobbers all existing configuration on the object. If you are adding
extra configuration, make sure you add it after this call.
Hard-Coding Credentials
Note
We recommend you not hard-code credentials inside an application. Use this method only for
small personal scripts or for testing purposes.
Version 0.9.1-pre.2 : Preview
5
AWS SDK for Node.js Getting Started Guide
Setting AWS Credentials

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Amazon AWS SDK and is the answer not in the manual?

Amazon AWS SDK Specifications

General IconGeneral
CategorySoftware Development Kit (SDK)
DeveloperAmazon Web Services (AWS)
LicenseApache License 2.0
PurposeTo enable developers to interact with AWS services from their applications.
Supported LanguagesJava, Python, JavaScript, .NET, Ruby, PHP, Go, C++
Supported AWS ServicesAll AWS services
Operating SystemsWindows, macOS, Linux
Latest VersionVaries by SDK and language. Refer to the official AWS documentation for the specific SDK.
RepositoryGitHub (for many SDKs)
DocumentationAvailable on the AWS website.
SDK FeaturesAPI abstraction, request signing, error handling, retry logic, data serialization, and support for various authentication methods.

Related product manuals