Socket
Socket
Sign inDemoInstall

@smithy/shared-ini-file-loader

Package Overview
Dependencies
2
Maintainers
2
Versions
42
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/shared-ini-file-loader

[![NPM version](https://img.shields.io/npm/v/@smithy/shared-ini-file-loader/latest.svg)](https://www.npmjs.com/package/@smithy/shared-ini-file-loader) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/shared-ini-file-loader.svg)](https://www.npmjs.c


Version published
Weekly downloads
16M
increased by6.34%
Maintainers
2
Install size
356 kB
Created
Weekly downloads
 

Package description

What is @smithy/shared-ini-file-loader?

@smithy/shared-ini-file-loader is a utility package for loading and parsing AWS credentials and configuration from INI files. It is commonly used in AWS SDKs to manage and access AWS credentials and configuration settings stored in shared INI files, such as the AWS credentials file and the AWS config file.

What are @smithy/shared-ini-file-loader's main functionalities?

Load AWS Credentials

This feature allows you to load AWS credentials from the shared credentials file. The code sample demonstrates how to use the `loadSharedConfigFiles` function to load and print the contents of the credentials file.

const { loadSharedConfigFiles } = require('@smithy/shared-ini-file-loader');

async function loadCredentials() {
  const { credentialsFile } = await loadSharedConfigFiles();
  console.log(credentialsFile);
}

loadCredentials();

Load AWS Configurations

This feature allows you to load AWS configurations from the shared config file. The code sample demonstrates how to use the `loadSharedConfigFiles` function to load and print the contents of the config file.

const { loadSharedConfigFiles } = require('@smithy/shared-ini-file-loader');

async function loadConfig() {
  const { configFile } = await loadSharedConfigFiles();
  console.log(configFile);
}

loadConfig();

Parse Specific Profile

This feature allows you to load and parse a specific profile from the shared INI files. The code sample demonstrates how to load the 'default' profile from the config and credentials files.

const { loadSharedConfigFiles } = require('@smithy/shared-ini-file-loader');

async function loadProfile(profile) {
  const { configFile, credentialsFile } = await loadSharedConfigFiles();
  const profileConfig = configFile[profile] || credentialsFile[profile];
  console.log(profileConfig);
}

loadProfile('default');

Other packages similar to @smithy/shared-ini-file-loader

Readme

Source

@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

FAQs

Last updated on 06 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc