Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(amplify-provider-awscloudformation): display mfa prompt #7866

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
70 changes: 50 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1243,30 +1243,38 @@ jobs:
environment:
TEST_SUITE: src/__tests__/frontend_config_drift.test.ts
CLI_REGION: eu-west-2
container-hosting-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_5
environment:
TEST_SUITE: src/__tests__/container-hosting.test.ts
CLI_REGION: eu-central-1
configure-project-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_5
environment:
TEST_SUITE: src/__tests__/configure-project.test.ts
CLI_REGION: eu-central-1
CLI_REGION: ap-northeast-1
auth_6-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_5
environment:
TEST_SUITE: src/__tests__/auth_6.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: ap-southeast-1
api_4-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_5
environment:
TEST_SUITE: src/__tests__/api_4.test.ts
CLI_REGION: ap-southeast-1
CLI_REGION: ap-southeast-2
schema-iterative-update-4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand Down Expand Up @@ -1997,6 +2005,16 @@ jobs:
TEST_SUITE: src/__tests__/frontend_config_drift.test.ts
CLI_REGION: eu-west-2
steps: *ref_6
container-hosting-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
resource_class: large
environment:
AMPLIFY_DIR: /home/circleci/repo/out
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux
TEST_SUITE: src/__tests__/container-hosting.test.ts
CLI_REGION: eu-central-1
steps: *ref_6
configure-project-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand All @@ -2005,7 +2023,7 @@ jobs:
AMPLIFY_DIR: /home/circleci/repo/out
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux
TEST_SUITE: src/__tests__/configure-project.test.ts
CLI_REGION: eu-central-1
CLI_REGION: ap-northeast-1
steps: *ref_6
auth_6-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
Expand All @@ -2015,7 +2033,7 @@ jobs:
AMPLIFY_DIR: /home/circleci/repo/out
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux
TEST_SUITE: src/__tests__/auth_6.test.ts
CLI_REGION: ap-northeast-1
CLI_REGION: ap-southeast-1
steps: *ref_6
api_4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
Expand All @@ -2025,7 +2043,7 @@ jobs:
AMPLIFY_DIR: /home/circleci/repo/out
AMPLIFY_PATH: /home/circleci/repo/out/amplify-pkg-linux
TEST_SUITE: src/__tests__/api_4.test.ts
CLI_REGION: ap-southeast-1
CLI_REGION: ap-southeast-2
steps: *ref_6
workflows:
version: 2
Expand Down Expand Up @@ -2144,19 +2162,19 @@ workflows:
- schema-predictions-amplify_e2e_tests
- amplify-configure-amplify_e2e_tests
- migration-node-function-amplify_e2e_tests
- configure-project-amplify_e2e_tests
- container-hosting-amplify_e2e_tests
- interactions-amplify_e2e_tests
- datastore-modelgen-amplify_e2e_tests
- layer-2-amplify_e2e_tests
- auth_6-amplify_e2e_tests
- configure-project-amplify_e2e_tests
- schema-data-access-patterns-amplify_e2e_tests
- init-special-case-amplify_e2e_tests
- iam-permissions-boundary-amplify_e2e_tests
- api_4-amplify_e2e_tests
- feature-flags-amplify_e2e_tests
- auth_6-amplify_e2e_tests
- schema-versioned-amplify_e2e_tests
- plugin-amplify_e2e_tests
- function_7-amplify_e2e_tests
- api_4-amplify_e2e_tests
- done_with_pkg_linux_e2e_tests:
requires:
- analytics-amplify_e2e_tests_pkg_linux
Expand All @@ -2174,19 +2192,19 @@ workflows:
- schema-predictions-amplify_e2e_tests_pkg_linux
- amplify-configure-amplify_e2e_tests_pkg_linux
- migration-node-function-amplify_e2e_tests_pkg_linux
- configure-project-amplify_e2e_tests_pkg_linux
- container-hosting-amplify_e2e_tests_pkg_linux
- interactions-amplify_e2e_tests_pkg_linux
- datastore-modelgen-amplify_e2e_tests_pkg_linux
- layer-2-amplify_e2e_tests_pkg_linux
- auth_6-amplify_e2e_tests_pkg_linux
- configure-project-amplify_e2e_tests_pkg_linux
- schema-data-access-patterns-amplify_e2e_tests_pkg_linux
- init-special-case-amplify_e2e_tests_pkg_linux
- iam-permissions-boundary-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux
- feature-flags-amplify_e2e_tests_pkg_linux
- auth_6-amplify_e2e_tests_pkg_linux
- schema-versioned-amplify_e2e_tests_pkg_linux
- plugin-amplify_e2e_tests_pkg_linux
- function_7-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux
- amplify_migration_tests_latest:
context:
- amplify-ecr-image-pull
Expand Down Expand Up @@ -2600,7 +2618,7 @@ workflows:
filters: *ref_10
requires:
- schema-iterative-update-1-amplify_e2e_tests
- configure-project-amplify_e2e_tests:
- container-hosting-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
Expand Down Expand Up @@ -2666,7 +2684,7 @@ workflows:
filters: *ref_10
requires:
- function_3-amplify_e2e_tests
- auth_6-amplify_e2e_tests:
- configure-project-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
Expand Down Expand Up @@ -2732,7 +2750,7 @@ workflows:
filters: *ref_10
requires:
- auth_5-amplify_e2e_tests
- api_4-amplify_e2e_tests:
- auth_6-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
Expand Down Expand Up @@ -2798,6 +2816,12 @@ workflows:
filters: *ref_10
requires:
- auth_1-amplify_e2e_tests
- api_4-amplify_e2e_tests:
context: *ref_8
post-steps: *ref_9
filters: *ref_10
requires:
- feature-flags-amplify_e2e_tests
- schema-iterative-update-4-amplify_e2e_tests_pkg_linux:
context: &ref_11
- amplify-ecr-image-pull
Expand Down Expand Up @@ -3082,7 +3106,7 @@ workflows:
filters: *ref_13
requires:
- schema-iterative-update-1-amplify_e2e_tests_pkg_linux
- configure-project-amplify_e2e_tests_pkg_linux:
- container-hosting-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
Expand Down Expand Up @@ -3152,7 +3176,7 @@ workflows:
filters: *ref_13
requires:
- function_3-amplify_e2e_tests_pkg_linux
- auth_6-amplify_e2e_tests_pkg_linux:
- configure-project-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
Expand Down Expand Up @@ -3222,7 +3246,7 @@ workflows:
filters: *ref_13
requires:
- auth_5-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux:
- auth_6-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
Expand Down Expand Up @@ -3292,3 +3316,9 @@ workflows:
filters: *ref_13
requires:
- auth_1-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux:
context: *ref_11
post-steps: *ref_12
filters: *ref_13
requires:
- feature-flags-amplify_e2e_tests_pkg_linux
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