Skip to content

Commit

Permalink
fix(amplify-provider-awscloudformation): display mfa prompt (aws-ampl…
Browse files Browse the repository at this point in the history
…ify#7866)

currently, the ora spinner is blocks the mfa prompt from appearing to the user. this commit makes sure a spinner is not running before prompting for mfa, then continues the spinner afterwords if required.
  • Loading branch information
johnpc committed Aug 25, 2021
1 parent 61d4baa commit 8947b18
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export class SSMClientWrapper {

const getSSMClient = async (context: $TSContext) => {
const spinner = ora('Initializing SSM Client');
context.exeInfo.spinner = spinner;
try {
spinner.start();

Expand Down
1 change: 1 addition & 0 deletions packages/amplify-cli/src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const spinner = ora('');
// to push his local developments
async function syncCurrentCloudBackend(context: $TSContext) {
context.exeInfo.restoreBackend = false;
context.exeInfo.spinner = spinner;

const currentEnv = context.exeInfo.localEnvInfo.envName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ async function getRoleCredentials(context: $TSContext, profileName: string, prof
context.print.info(` ${profileConfig.role_arn}`);
context.print.info('It requires MFA authentication. The MFA device is');
context.print.info(` ${profileConfig.mfa_serial}`);
mfaTokenCode = await getMfaTokenCode();
mfaTokenCode = await getMfaTokenCode(context);
}
logger('getRoleCredentials.aws.STS', [sourceProfileAwsConfig])();
const sts = new aws.STS(sourceProfileAwsConfig);
Expand Down Expand Up @@ -156,7 +156,11 @@ async function getRoleCredentials(context: $TSContext, profileName: string, prof
return roleCredentials;
}

async function getMfaTokenCode() {
async function getMfaTokenCode(context) {
let spinner;
if (context.exeInfo.spinner && context.exeInfo.spinner.isSpinning) {
spinner = context.exeInfo.spinner.stopAndPersist();
}
const inputMfaTokenCode = {
type: 'input',
name: 'tokenCode',
Expand All @@ -174,6 +178,7 @@ async function getMfaTokenCode() {
},
};
const answer = await inquirer.prompt(inputMfaTokenCode);
if (spinner) spinner.start();
return answer.tokenCode;
}

Expand Down

0 comments on commit 8947b18

Please sign in to comment.