Skip to content

Commit 87a6b4c

Browse files
authored
fix: add opt-out for appId mismatch check during init (#14013)
* chore: add opt-out for appId mismatch during init via environment variable * chore: update messaging
1 parent b40e8e8 commit 87a6b4c

File tree

1 file changed

+14
-9
lines changed
  • packages/amplify-cli/src/commands

1 file changed

+14
-9
lines changed

packages/amplify-cli/src/commands/init.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,20 @@ export const run = async (context: $TSContext): Promise<void> => {
3333
constructExeInfo(context);
3434
checkForNestedProject();
3535

36-
const projectPath = process.cwd();
37-
if (stateManager.metaFileExists(projectPath)) {
38-
const inputAppId = context.exeInfo?.inputParams?.amplify?.appId;
39-
const appId = getAmplifyAppId();
40-
if (inputAppId && appId && inputAppId !== appId) {
41-
throw new AmplifyError('InvalidAmplifyAppIdError', {
42-
message: `Amplify appId mismatch.`,
43-
resolution: `You are currently working in the amplify project with Id ${appId}`,
44-
});
36+
// Opt-out mechanism for customers that are using old app backend environments with existing apps intentionally
37+
const { AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK } = process.env;
38+
if (AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK !== 'true') {
39+
// check for appId mismatch
40+
const projectPath = process.cwd();
41+
if (stateManager.metaFileExists(projectPath)) {
42+
const inputAppId = context.exeInfo?.inputParams?.amplify?.appId;
43+
const appId = getAmplifyAppId();
44+
if (inputAppId && appId && inputAppId !== appId) {
45+
throw new AmplifyError('InvalidAmplifyAppIdError', {
46+
message: `Amplify appId mismatch.`,
47+
resolution: `You are currently working in the amplify project with Id ${appId}. If this is intentional, you may bypass this protection by setting the environment variable AMPLIFY_SKIP_APP_ID_MISMATCH_CHECK to true.`,
48+
});
49+
}
4550
}
4651
}
4752

0 commit comments

Comments
 (0)