18
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nodejsのaws-sdkを使うときに `~/.aws/credentials` を使う方法

Posted at

設定ファイルを以下のように作成して

~/.aws/credentials
[default]
aws_access_key_id = xxxxxx
aws_secret_access_key = yyyyy
region = ap-northeast-1

以下を実行すると Missing region in config で怒られる

const AWS = require('aws-sdk')

const config = AWS.Config
const eb = new AWS.ElasticBeanstalk()

eb.describeEnvironments({EnvironmentNames: ['hogehoge']}, (err, data) => {
    console.log(err)
    console.log(data)
})
$ node app.js
{ ConfigError: Missing region in config
....

configファイルを使う場合は AWS_SDK_LOAD_CONFIG=true を設定してあげる必要があるみたい

$ env AWS_SDK_LOAD_CONFIG=true node app.js

参考: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-region.html

18
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?