Skip to content

Commit

Permalink
chore(amplify-provider-awscloudformation): add env vars for configuri…
Browse files Browse the repository at this point in the history
…ng development against beta/gamma (#8121)
  • Loading branch information
johnpc authored Sep 9, 2021
1 parent 934dc23 commit 13abcf4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/amplify-cli/src/pre-deployment-pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import * as path from 'path';

export async function preDeployPullBackend(context: $TSContext, sandboxId: string) {
const providerPlugin = await import(context.amplify.getProviderPlugins(context).awscloudformation);

const url = `${providerPlugin.adminBackendMap['us-east-1'].appStateUrl}/AppState/${sandboxId}`;
// environment variable AMPLIFY_CLI_APPSTATE_BASE_URL useful for development against beta/gamma appstate endpoints
const appStateBaseUrl = process.env.AMPLIFY_CLI_APPSTATE_BASE_URL ?? providerPlugin.adminBackendMap['us-east-1'].appStateUrl;
const url = `${appStateBaseUrl}/AppState/${sandboxId}`;

// Fetch schema
const res = await fetch(`${url}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export async function adminLoginFlow(context: $TSContext, appId: string, envName
const spinner = ora('Continue in browser to log in…\n').start();
try {
// spawn express server locally to get credentials
const originUrl = adminBackendMap[region].amplifyAdminUrl;
// environment variable AMPLIFY_CLI_ADMINUI_BASE_URL is used to set the login url to http://localhost:3000 when developing against beta/gamma endpoints
const originUrl = process.env.AMPLIFY_CLI_ADMINUI_BASE_URL ?? adminBackendMap[region]?.amplifyAdminUrl;
const adminLoginServer = new AdminLoginServer(appId, originUrl, context.print);
await new Promise<void>(resolve =>
adminLoginServer.startServer(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { adminLoginFlow } from '../admin-login';
import { AdminAuthConfig, AwsSdkConfig, CognitoAccessToken, CognitoIdToken } from './auth-types';

export const adminVerifyUrl = (appId: string, envName: string, region: string): string => {
const baseUrl = adminBackendMap[region].amplifyAdminUrl;
const baseUrl = process.env.AMPLIFY_CLI_ADMINUI_BASE_URL ?? adminBackendMap[region]?.amplifyAdminUrl;
return `${baseUrl}/admin/${appId}/${envName}/verify/`;
};

Expand Down Expand Up @@ -45,7 +45,9 @@ export async function getTempCredsWithAdminTokens(context: $TSContext, appId: st
}

async function getAdminAppState(appId: string, region: string) {
const res = await fetch(`${adminBackendMap[region].appStateUrl}/AppState/?appId=${appId}`);
// environment variable AMPLIFY_CLI_APPSTATE_BASE_URL useful for development against beta/gamma appstate endpoints
const appStateBaseUrl = process.env.AMPLIFY_CLI_APPSTATE_BASE_URL ?? adminBackendMap[region].appStateUrl;
const res = await fetch(`${appStateBaseUrl}/AppState/?appId=${appId}`);
return res.json();
}

Expand Down

0 comments on commit 13abcf4

Please sign in to comment.