aws-select-profile
by Daniel Schroeder
Select AWS profile from you AWS config
const region = await env('AWS_PROFILE');
// Menu: AWS Select Profile// Description: Select AWS profile from you AWS config// Author: Daniel Schroeder// Twitter: @udondanimport { readFileSync } from 'fs';const ini = await npm('ini');const awsConf = `${process.env.HOME}/.aws/config`;const config = ini.parse(readFileSync(awsConf, 'utf-8'));const currentMarker = ' ★';const currentProfile = env['AWS_PROFILE'];const sections = Object.keys(config).reduce(function (filtered, section) {if (section.startsWith('profile ')) {let profileName = section.replace('profile ', '');if (profileName == currentProfile) {profileName += currentMarker;}filtered.push(profileName);}return filtered;}, []);const profile = await arg({placeholder: 'Select profile',hint: `parsed from ${awsConf}`,},sections.sort());await cli('set-env-var', 'AWS_PROFILE', profile.replace(currentMarker, ''));