0

I am attempting to use the AWS SDK for JavaScript. This process requires creating a credential file as explained here:

However I am unable to create this file as descibed for Windows. On Windows systems I am supposed to save the files here: C:\Users\USERNAME\.aws\credentials.

But I am unable to create a path such as .aws.

Also ruining npm install aws-sdk --save as indicated on the resource page, there are no such folders created for me to add the file.

How do I create this file?

1
  • You don't need a credentials file. There are many other options to provide credentials, for example from an IAM role, inline in code, from an external JSON file, and from environment variables. That said, why can't you create a folder name .aws in %USERPROFILE%? Commented Mar 21, 2018 at 23:50

2 Answers 2

2

Adding to Toms Answer:

  1. Manual way of creating the aws file. -> Covered by Tom
  2. Automatic way of doing it by using the CLI. -> Covered by Tom.
  3. Programmatic way of doing this:

     var AWS = require('aws-sdk');
     console.log("Configuring AWS SDK with %s region", argv.region);
     AWS.config.update({ accessKeyId: accessKey, secretAccessKey: secretKey, region: region });
    
  4. Environment Variables - The SDK can pick up these Env Variables, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN

  5. Loading from a JSON file, you can use AWS.config.loadFromPath('/path/') to load from a config file.

  6. If your code is running in a AWS EC2, you can set an IAM role on the EC2 and the SDK can pick that up to configure itself automatically.

For further reading use this: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html

Personally, I would recommend using either options 3, 4, 5 or 6, this makes your code portable and deploy-able across environments .

Sign up to request clarification or add additional context in comments.

Comments

1

Option 1: MANUAL

Open CMD in the C:\Users\USERNAME directory (should be default)

Run the following command in CMD: mkdir .aws

Create the credentials file and add your credentials manually

Option 2: AUTOMATIC

Install the AWS CLI This will give you access to running AWS commands from the command line. Then since you're using a windows machine, open up CMD and run the following command:

aws configure

It will ask you for some details such as Access Key ID and Secret Access Key as well as your preferred region and data type.

When you enter these details, it will create the .aws/credentials file for you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.