Socket
Socket
Sign inDemoInstall

@aws-sdk/shared-ini-file-loader

Package Overview
Dependencies
2
Maintainers
5
Versions
111
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/shared-ini-file-loader


Version published
Weekly downloads
3.9M
decreased by-5.97%
Maintainers
5
Created
Weekly downloads
 

Package description

What is @aws-sdk/shared-ini-file-loader?

@aws-sdk/shared-ini-file-loader is a package from the AWS SDK for JavaScript that provides utilities for loading and parsing AWS credentials and configuration from INI files. This is particularly useful for managing multiple AWS profiles and credentials in a standardized way.

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

Load AWS Credentials from INI File

This feature allows you to load AWS credentials from the shared INI file. The `loadSharedConfigFiles` function reads the credentials and configuration files and returns their contents.

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

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

loadCredentials();

Load AWS Configurations from INI File

This feature allows you to load AWS configurations from the shared INI file. The `loadSharedConfigFiles` function reads the configuration file and returns its contents.

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

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

loadConfig();

Parse Specific Profile

This feature allows you to parse and load a specific AWS profile from the shared INI files. The `parseKnownFiles` function can be used to specify which profile to load.

const { parseKnownFiles } = require('@aws-sdk/shared-ini-file-loader');

async function loadProfile(profileName) {
  const { credentialsFile, configFile } = await parseKnownFiles({ profile: profileName });
  console.log(credentialsFile[profileName], configFile[profileName]);
}

loadProfile('my-profile');

Other packages similar to @aws-sdk/shared-ini-file-loader

Changelog

Source

3.272.0 (2023-02-15)

Features

  • client-cloudtrail: This release adds an InsufficientEncryptionPolicyException type to the StartImport endpoint (4253089)
  • client-frauddetector: This release introduces Lists feature which allows customers to reference a set of values in Fraud Detector's rules. With Lists, customers can dynamically manage these attributes in real time. Lists can be created/deleted and its contents can be modified using the Fraud Detector API. (6186c03)
  • client-glue: Fix DirectJDBCSource not showing up in CLI code gen (bedba23)
  • client-privatenetworks: This release introduces a new StartNetworkResourceUpdate API, which enables return/replacement of hardware from a NetworkSite. (804b9bc)
  • client-wafv2: For protected CloudFront distributions, you can now use the AWS WAF Fraud Control account takeover prevention (ATP) managed rule group to block new login attempts from clients that have recently submitted too many failed login attempts. (dc28d4e)
  • clients: update client endpoints as of 2023-02-15 (2e05ae8)

Readme

Source

@aws-sdk/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.

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 15 Feb 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