Amazon AWS Error: Missing credentials in config node.js
<p>I am just getting started using AWS and I'm trying to use their example code <a href="http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-examples.html" rel="nofollow">here.</a>  I am using dotenv to store my keys as environmental variables.  Using coffee script my code looks like this:</p>

<pre><code>require('dotenv').config()

express = require 'express'
router = express.Router()

AWS = require('aws-sdk')
AWS.config.region = 'us-west-2'

s3bucket = new (AWS.S3)(params: Bucket: 'new-bucket-name')

s3bucket.createBucket -&gt;
  params = 
    Key: process.env.AWS_ACCESS_KEY_ID
    Body: 'Hello!'
  s3bucket.upload params, (err, data) -&gt;
    if err
      console.log 'Error uploading data: ', err
    else
      console.log 'Successfully uploaded data to myBucket/myKey'
    return
  return
</code></pre>

<p>But I keep getting the following error: </p>

<pre><code>message: 'Missing credentials in config',
  code: 'CredentialsError',
  errno: 'EHOSTDOWN',
  syscall: 'connect',
  address: '169.254.169.254',
  port: 80,
  time: 2016-10-13T14:14:03.605Z,
  originalError: 
   { message: 'Could not load credentials from any providers',
     code: 'CredentialsError',
     errno: 'EHOSTDOWN',
     syscall: 'connect',
     address: '169.254.169.254',
     port: 80,
     time: 2016-10-13T14:14:03.605Z,
     originalError: 
      { message: 'Missing credentials in config',
        code: 'CredentialsError',
        errno: 'EHOSTDOWN',
        syscall: 'connect',
        address: '169.254.169.254',
        port: 80,
        time: 2016-10-13T14:14:03.599Z,
        originalError: [Object] } } }
</code></pre>

<p>How do I fix this, do I also need to send my secret key somehow?</p>

<p>UPDATE:
fixed it using </p>

<pre><code>AWS.config = new AWS.Config();
AWS.config.accessKeyId = "accessKey";
AWS.config.secretAccessKey = "secretKey";
</code></pre>

<p>but now I am getting this new error:</p>

<pre><code>  message: 'Access Denied',
  code: 'AccessDenied',
  region: null,
  time: 2016-10-13T14:38:19.651Z,
  requestId: '958BD7EA261F2DCA',
  extendedRequestId: 'xuBSmGL/GC5Tx1osMh9tBFIwXMLy15VtJXniwYVGutTcoBJgrCeOLZpQMlliF1Azrkmj1tsAX7o=',
  cfId: undefined,
  statusCode: 403,
  retryable: false,
  retryDelay: 11.225715031927086 }
</code></pre>