npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aws-profile-handler

v2.0.3

Published

dealing with aws credentials a little bit eaiser

Downloads

8,309

Readme

aws-profile-handler

Simply tool for extracting and editing the .aws/credentials. You can add, get, list, and delete profile(s) synchronously, no 3p dependencies introduced.

Build Status Coverage Status GitHub license GitHub issues Maintainability dependencies Status npm version

How do I install it?

Install it into your package

npm install aws-profile-handler --save

Add a profile

let valid_credential_object = {
        "aws_access_key_id": "123",
        "aws_secret_access_key": "456"
};

let awsProfiler = require('aws-profile-handler');

// AWS credentials file path is optional as the last parameter. Default to ~/.aws/credentials
awsProfiler.addProfile('awesomeProfileName', valid_credential_object); 
awsProfiler.addProfile('awesomeProfileName', valid_credential_object, 'file/path/to/aws/credentials'); 


// .aws/credentials 
[awesomeProfileName]
aws_access_key_id=123
aws_secret_access_key=456

Get a profile's credentials


let awsProfiler = require('aws-profile-handler');

// AWS credentials file path is optional as the last parameter. Default to ~/.aws/credentials
awsProfiler.getProfileCredentials('awesomeProfileName');
awsProfiler.getProfileCredentials('awesomeProfileName', 'file/path/to/aws/credentials');


// return 'null' if profile doesn't exist
// return an object with 'aws_access_key_id' and 'aws_access_key_id'
{
    "aws_access_key_id": "123",
    "aws_secret_access_key": "456"
}

List profiles

let awsProfiler = require('aws-profile-handler');

// AWS credentials file path is optional as the last parameter. Default to ~/.aws/credentials
awsProfiler.listProfiles();
awsProfiler.listProfiles('file/path/to/aws/credentials');

// return a list of all the profiles' name
// ['awesomeProfileName', 'something', 'else', 'if', 'exists'];

Delete a profile

let awsProfiler = require('aws-profile-handler');

// AWS credentials file path is optional as the last parameter. Default to ~/.aws/credentials
awsProfiler.deleteProfile('lameProfileName');
awsProfiler.deleteProfile('lameProfileName', 'file/path/to/aws/credentials');

Error

Four customized errors would be thrown.

  1. If format is invalid.
// error.message:
'Invalid AWS credential file. Cannot have nested sessions'
  1. If one or more values are missing.
// .aws/credentials
[badProfile]
aws_access_key_id=
aws_secret_access_key=idIsMissing

// error.message
'Invalid AWS credential file. Incomplete key/value pair'
  1. If input credentials object is invalid.
let missingOneKey = {
    aws_access_key_id: 1
}

let haveOneExtraKey = {
    aws_access_key_id: 1,
    aws_secret_access_key: 2,
    extra: 3
}

let wrongName = {
    aws_secret_access_key: 2,
    extra: 3
}

// error.message
'Invalid input: credentials schema is invalid.'
  1. If require input parameters are missing.
awsProfileHandler.addProfile();
// error.message
'Invalid Input: profile name cannot be omitted nor only contains white spaces.'

awsProfileHandler.addProfile('profile');
// error.message
'Invalid Input: credentials cannot be omitted nor empty.'

Note:

Version 1.X.X is deprecated, the last V1 update was 1.1.0.