-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5fa3a77
Showing
13 changed files
with
2,093 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
env: { | ||
es6: true, | ||
node: true, | ||
}, | ||
plugins: [ | ||
"@typescript-eslint/eslint-plugin" | ||
], | ||
extends: [ | ||
"standard-with-typescript" | ||
], | ||
rules:{ | ||
"no-empty": [2, { "allowEmptyCatch": true }], | ||
}, | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
ignorePatterns: ['.eslintrc.cjs', "bin/**/*.js"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
yarn-error.log | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
yarn-error.log | ||
demo-aws-user.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Andrei O. (andrei0x309) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#!/usr/bin/env node | ||
import yargs from 'yargs' | ||
import { hideBin } from 'yargs/helpers' | ||
import { | ||
listUsers, | ||
createUser, | ||
deleteUser, | ||
switchUser, | ||
showUser, | ||
wipeStore, | ||
logout, | ||
showHelp | ||
} from "./../lib/index.js"; | ||
|
||
yargs(hideBin(process.argv)) | ||
.scriptName('aws-user') | ||
.command({ | ||
command: "add <loginString>", | ||
desc: "This command will add an AWS user to the store", | ||
handler: (argv) => { | ||
createUser(argv.loginString); | ||
}, | ||
}) | ||
.command({ | ||
command: "remove <user>", | ||
desc: "This command will remove an AWS user from the store if found", | ||
handler: (argv) => { | ||
deleteUser(argv.user); | ||
}, | ||
}) | ||
.command({ | ||
command: "switch <user>", | ||
desc: "This command will switch login to the user specified", | ||
handler: (argv) => { | ||
switchUser(argv.user); | ||
}, | ||
}) | ||
.command({ | ||
command: "list", | ||
desc: "This will show all users", | ||
handler: (argv) => { | ||
listUsers(); | ||
}, | ||
}) | ||
.command({ | ||
command: "show <user>", | ||
desc: "This will show the user specified", | ||
handler: (argv) => { | ||
showUser(argv.user); | ||
} | ||
}) | ||
.command({ | ||
command: "wipe", | ||
desc: "This will wipe the local store of this lib located at ~/.aws/store.json", | ||
handler: (argv) => { | ||
wipeStore(); | ||
}, | ||
}) | ||
.command({ | ||
command: "loggout", | ||
desc: "This command will logout current AWS user", | ||
handler: (argv) => { | ||
logout(); | ||
}, | ||
}) | ||
.command({ | ||
command: "help", | ||
desc: "This command will show a detalied help message", | ||
handler: (argv) => { | ||
showHelp(); | ||
}, | ||
}) | ||
.demandCommand(1, "You need to invoke a command use help to see commands") | ||
.parse(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{ | ||
"name": "aws-user", | ||
"version": "1.0.0", | ||
"description": "Simple command utility to help you manage and switch between multiple AWS CLI users. use aws-user --help for usage information.", | ||
"main": "./lib/index.js", | ||
"types": "./lib/index.d.ts", | ||
"repository": "andrei0x309/aws-user", | ||
"author": "andrei0x309 <andrei@flashsoft.eu>", | ||
"license": "MIT", | ||
"type": "module", | ||
"scripts": { | ||
"docs": "node -e 0", | ||
"lint": "eslint ./src --ext .ts", | ||
"lint-fix": "eslint ./src --fix --ext .ts", | ||
"prepare": "yarn build", | ||
"prepublishOnly": "yarn lint", | ||
"preversion": "yarn lint", | ||
"release": "yarn preversion && yarn config set version-tag-prefix aws-user@v && yarn config set version-git-message aws-user@v%s' && yarn version --patch && yarn postversion", | ||
"postversion": "git push && git push --tags", | ||
"build": "tsc --project .", | ||
"postinstall": "yarn build" | ||
}, | ||
"engines": { | ||
"node": ">=16" | ||
}, | ||
"keywords": [ | ||
"aws-user", | ||
"aws user management", | ||
"aws local user management", | ||
"aws user util" | ||
], | ||
"devDependencies": { | ||
"@types/node": "^18.7.8", | ||
"@typescript-eslint/eslint-plugin": "^5.33.1", | ||
"@typescript-eslint/parser": "^5.33.1", | ||
"eslint": "^8.22.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-config-standard-with-typescript": "^22.0.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jest": "^26.8.4", | ||
"eslint-plugin-n": "^15.2.4", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-promise": "^6.0.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"yarn-upgrade-all": "^0.7.1" | ||
}, | ||
"dependencies": { | ||
"conf": "^10.2.0", | ||
"typescript": "^4.7.4", | ||
"yargs": "^17.5.1" | ||
}, | ||
"bin": { | ||
"aws-user": "bin/cli.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/andrei0x309/aws-user/issues" | ||
}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"homepage": "https://github.com/andrei0x309/aws-user#readme", | ||
"directories": { | ||
"lib": "lib" | ||
}, | ||
"gitHead": "babb041828cab50c525e0b9aab02d58f73416ef3" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# aws-user | ||
|
||
## Description | ||
|
||
This is a simple command utility to mange and switch between multiple AWS users. | ||
|
||
Use aws-user help to get all available commands. | ||
|
||
Can be helpful if you have more than one user with diffrent permissions, or users in multiple organizations. | ||
|
||
The storage is done localy in the same place where aws credentials are stored, you need to have AWS CLI installed as it assumes the credentials folder exists. | ||
|
||
**Note:** | ||
|
||
## Install | ||
|
||
```bash | ||
yarn global add aws-user | ||
``` | ||
|
||
## Usage | ||
|
||
Get commands: | ||
|
||
```bash | ||
aws-user help | ||
``` | ||
|
||
Add User: | ||
|
||
```bash | ||
aws-user add <user>:<access-key>:<secret-key> | ||
``` | ||
|
||
Example: | ||
|
||
```bash | ||
aws-user add john22:ASIARNQFX7RWNRAAI2VVO:TTgFyl0p/2kxXa/uJ9i9sabBn22b2sewLXjaXPPY | ||
``` | ||
|
||
## Notes | ||
|
||
It has commands to switch between users, add users, remove users, wipe local storage, list all users, and loggout from AWS. | ||
|
||
## Visual Demo | ||
|
||
Example of using `aws-user` comand util | ||
![aws-user Demo](/demo-aws-user.gif?raw=true "aws-user Demo") | ||
|
||
## Contributing | ||
|
||
Issues and pull requests are welcome. | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
|
||
import { | ||
showUser as utilShowUser, | ||
removeUser, | ||
switchAwsCredentials, | ||
addUser, | ||
getAwsCredentials, | ||
libWipeStore, | ||
libLogout, | ||
} from './utils.js' | ||
|
||
export const listUsers = (): void => { | ||
const credentials = getAwsCredentials() | ||
if (credentials == null) { | ||
console.log('[ERROR]: no users found') | ||
return | ||
} | ||
console.log(JSON.stringify(credentials, null, 2)) | ||
} | ||
|
||
export const createUser = (loginString: string): void => { | ||
const login = loginString.split(':') | ||
if (login.length !== 3) { | ||
console.log('[ERROR]: userString invalid format usename:AWS_ACCOUNT_ID:AWS_SECRET_ACCESS_KEY \n Example: john22:ASIARNQFX7RWNRAAI2VVO:TTgFyl0p/2kxXa/uJ9i9sabBn22b2sewLXjaXPPY') | ||
return | ||
} | ||
const [account, id, pass] = login | ||
const user = { account, id, pass } | ||
addUser(user) | ||
} | ||
|
||
export const deleteUser = (account: string): void => { | ||
removeUser(account) | ||
} | ||
|
||
export const switchUser = (account: string): void => { | ||
switchAwsCredentials(account) | ||
} | ||
|
||
export const showUser = (account: string): void => { | ||
utilShowUser(account) | ||
} | ||
|
||
export const wipeStore = (): void => { | ||
libWipeStore() | ||
} | ||
|
||
export const logout = (): void => { | ||
libLogout() | ||
} | ||
|
||
export const showHelp = (): void => { | ||
console.log('[INFO]: usage: \n\n') | ||
console.log('[INFO]: aws-user list \n') | ||
console.log('[INFO]: aws-user create <user> \n Example: aws-user create john22:ASIARNQFX7RWNRAAI2VVO:TTgFyl0p/2kxXa/uJ9i9sabBn22b2sewLXjaXPPY\n\n') | ||
console.log('[INFO]: aws-user delete <user> \n') | ||
console.log('[INFO]: aws-user switch <user> \n') | ||
console.log('[INFO]: aws-user show <user>\n') | ||
console.log('[INFO]: aws-user wipe \n') | ||
console.log('[INFO]: aws-user list \n') | ||
console.log('[INFO]: aws-user loggout \n') | ||
console.log('[INFO]: aws-user help \n') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const fileDBSchema: any = { | ||
users: { | ||
type: 'array', | ||
items: { | ||
type: 'object', | ||
properties: { | ||
account: { | ||
type: 'string' | ||
}, | ||
id: { | ||
type: 'string' | ||
}, | ||
pass: { | ||
type: 'string' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
export { fileDBSchema } |
Oops, something went wrong.