2.4.0 • Published 2 months ago

@smithy/shared-ini-file-loader v2.4.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 months ago

@smithy/shared-ini-file-loader

NPM version NPM downloads

AWS Shared Configuration File Loader

This module provides a function that reads from AWS SDK configuration files and returns a promise that will resolve with a hash of the parsed contents of the AWS credentials file and of the AWS config file. Given the sample files below, the promise returned by loadSharedConfigFiles would resolve with:

{
  configFile: {
    'default': {
      aws_access_key_id: 'foo',
      aws_secret_access_key: 'bar',
    },
    dev: {
      aws_access_key_id: 'foo1',
      aws_secret_access_key: 'bar1',
    },
    prod: {
      aws_access_key_id: 'foo2',
      aws_secret_access_key: 'bar2',
    },
    'testing host': {
      aws_access_key_id: 'foo4',
      aws_secret_access_key: 'bar4',
    }
  },
  credentialsFile: {
    'default': {
      aws_access_key_id: 'foo',
      aws_secret_access_key: 'bar',
    },
    dev: {
      aws_access_key_id: 'foo1',
      aws_secret_access_key: 'bar1',
    },
    prod: {
      aws_access_key_id: 'foo2',
      aws_secret_access_key: 'bar2',
    }
  },
}

If a file is not found, its key (configFile or credentialsFile) will instead have a value of an empty object.

Supported configuration

You may customize how the files are loaded by providing an options hash to the loadSharedConfigFiles function. The following options are supported:

  • filepath - The path to the shared credentials file. If not specified, the provider will use the value in the AWS_SHARED_CREDENTIALS_FILE environment variable or a default of ~/.aws/credentials.
  • configFilepath - The path to the shared config file. If not specified, the provider will use the value in the AWS_CONFIG_FILE environment variable or a default of ~/.aws/config.
  • ignoreCache - The provider will normally cache the contents of the files it loads. This option will force the provider to reload the files from disk. Defaults to false.

Sample files

~/.aws/credentials

[default]
aws_access_key_id=foo
aws_secret_access_key=bar

[dev]
aws_access_key_id=foo2
aws_secret_access_key=bar2

[prod]
aws_access_key_id=foo3
aws_secret_access_key=bar3

~/.aws/config

[default]
aws_access_key_id=foo
aws_secret_access_key=bar

[profile dev]
aws_access_key_id=foo2
aws_secret_access_key=bar2

[profile prod]
aws_access_key_id=foo3
aws_secret_access_key=bar3

[profile "testing host"]
aws_access_key_id=foo4
aws_secret_access_key=bar4
2.4.0

2 months ago

2.3.5

2 months ago

2.3.4

2 months ago

2.3.3

2 months ago

2.3.2

2 months ago

2.3.1

4 months ago

2.3.0

4 months ago

2.2.8

4 months ago

2.2.7

5 months ago

2.2.6

5 months ago

1.0.2

10 months ago

1.1.0

9 months ago

1.0.3

9 months ago

2.2.1

7 months ago

2.0.3

9 months ago

2.2.0

7 months ago

2.0.2

9 months ago

2.2.3

6 months ago

2.0.13

7 months ago

2.0.5

8 months ago

2.2.2

7 months ago

2.0.4

9 months ago

2.2.5

5 months ago

2.0.11

8 months ago

2.0.7

8 months ago

2.2.4

6 months ago

2.0.12

7 months ago

2.0.6

8 months ago

2.0.9

8 months ago

2.0.10

8 months ago

2.0.8

8 months ago

2.1.0

7 months ago

2.0.1

9 months ago

2.0.0

9 months ago

1.0.1

11 months ago

1.0.0

11 months ago