6.0.0 • Published 10 months ago

@campus-explorer/aws-credentials v6.0.0

Weekly downloads
183
License
MIT
Repository
github
Last release
10 months ago

@campus-explorer/aws-credentials

JavaScript helper code to manage AWS credentials

Install

yarn add @campus-explorer/aws-credentials

Usage

import AWS from 'aws-sdk';
import {
    getProfileCredentials,
    useProfile,
    getProfileConfig,
} from '@campus-explorer/aws-credentials';

# Get an AWS.Credentials object for the profile
const credentials = await getProfileCredentials('my-profile');

# Alternatively, set AWS to use the profile
await useProfile('my-profile', AWS.config);

# See if a profile exists
try {
    getProfileConfig('my-profile');
} catch (error) {
    // doesn't exist
}

Description

This package is similar to AWS.SharedIniFileCredentials, in that it loads credentials using the shared credentials file. However, it adds a few features:

  • integration with the AWS CLI cache
  • longer durations

Session Durations

By default, we will cache profiles that end in '-admin' for 1 hour, and all other profiles for 8 hours.

Functions

getProfileCredentials()

Returns an AWS.Credentials object.

getProfileCredentials(
    profile,
    { // optional options
        cacheDir, // optional, defaults to ~/.aws/cli/cache
        duration, // optional, defaults to duration rules noted above,
        getMfaToken, // optional, defaults to using inquirer
    },
})

useProfile()

Loads the profile's credential into the environment and the global credentials settings for the AWS SDK. You need to pass your copy of the AWS object.

useProfile({
    profile,
    AWS,
    {
        /* ... same options as getProfileCredentials() */
    }
})
6.0.0

10 months ago

4.3.4

2 years ago

4.3.2

2 years ago

4.3.1

2 years ago

4.3.3

2 years ago

4.3.0

2 years ago

4.2.3

2 years ago

4.2.2

2 years ago

4.2.1

2 years ago

4.1.0

3 years ago

4.2.0

3 years ago

3.0.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

4.0.2

3 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.3

4 years ago

2.2.2

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago