Skip to content

Commit

Permalink
Revert "feat: defer root stack creation to first amplify push (aws-…
Browse files Browse the repository at this point in the history
…amplify#7174)" (aws-amplify#7306)

This reverts commit d28dd1c.
  • Loading branch information
edwardfoyle authored and cjihrig-aws committed Jul 12, 2021
1 parent 872602e commit 28b6a21
Show file tree
Hide file tree
Showing 18 changed files with 124 additions and 348 deletions.
58 changes: 14 additions & 44 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1127,30 +1127,22 @@ jobs:
environment:
TEST_SUITE: src/__tests__/function_5.test.ts
CLI_REGION: eu-central-1
defer-init-push-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_4
environment:
TEST_SUITE: src/__tests__/defer-init-push.test.ts
CLI_REGION: ap-northeast-1
configure-project-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_4
environment:
TEST_SUITE: src/__tests__/configure-project.test.ts
CLI_REGION: ap-southeast-1
CLI_REGION: ap-northeast-1
api_4-amplify_e2e_tests:
working_directory: ~/repo
docker: *ref_1
resource_class: large
steps: *ref_4
environment:
TEST_SUITE: src/__tests__/api_4.test.ts
CLI_REGION: ap-southeast-2
CLI_REGION: ap-southeast-1
schema-iterative-update-4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand Down Expand Up @@ -1821,16 +1813,6 @@ jobs:
TEST_SUITE: src/__tests__/function_5.test.ts
CLI_REGION: eu-central-1
steps: *ref_5
defer-init-push-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__/defer-init-push.test.ts
CLI_REGION: ap-northeast-1
steps: *ref_5
configure-project-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
docker: *ref_1
Expand All @@ -1839,7 +1821,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: ap-southeast-1
CLI_REGION: ap-northeast-1
steps: *ref_5
api_4-amplify_e2e_tests_pkg_linux:
working_directory: ~/repo
Expand All @@ -1849,7 +1831,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-2
CLI_REGION: ap-southeast-1
steps: *ref_5
workflows:
version: 2
Expand Down Expand Up @@ -1968,15 +1950,15 @@ workflows:
- containers-api-amplify_e2e_tests
- interactions-amplify_e2e_tests
- datastore-modelgen-amplify_e2e_tests
- defer-init-push-amplify_e2e_tests
- configure-project-amplify_e2e_tests
- schema-iterative-update-2-amplify_e2e_tests
- schema-data-access-patterns-amplify_e2e_tests
- init-special-case-amplify_e2e_tests
- configure-project-amplify_e2e_tests
- api_4-amplify_e2e_tests
- auth_1-amplify_e2e_tests
- feature-flags-amplify_e2e_tests
- schema-versioned-amplify_e2e_tests
- plugin-amplify_e2e_tests
- api_4-amplify_e2e_tests
- done_with_pkg_linux_e2e_tests:
requires:
- schema-key-amplify_e2e_tests_pkg_linux
Expand All @@ -1998,15 +1980,15 @@ workflows:
- containers-api-amplify_e2e_tests_pkg_linux
- interactions-amplify_e2e_tests_pkg_linux
- datastore-modelgen-amplify_e2e_tests_pkg_linux
- defer-init-push-amplify_e2e_tests_pkg_linux
- configure-project-amplify_e2e_tests_pkg_linux
- schema-iterative-update-2-amplify_e2e_tests_pkg_linux
- schema-data-access-patterns-amplify_e2e_tests_pkg_linux
- init-special-case-amplify_e2e_tests_pkg_linux
- configure-project-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux
- auth_1-amplify_e2e_tests_pkg_linux
- feature-flags-amplify_e2e_tests_pkg_linux
- schema-versioned-amplify_e2e_tests_pkg_linux
- plugin-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 @@ -2421,7 +2403,7 @@ workflows:
filters: *ref_9
requires:
- migration-api-key-migration1-amplify_e2e_tests
- defer-init-push-amplify_e2e_tests:
- configure-project-amplify_e2e_tests:
context: *ref_7
post-steps: *ref_8
filters: *ref_9
Expand Down Expand Up @@ -2481,7 +2463,7 @@ workflows:
filters: *ref_9
requires:
- layer-amplify_e2e_tests
- configure-project-amplify_e2e_tests:
- api_4-amplify_e2e_tests:
context: *ref_7
post-steps: *ref_8
filters: *ref_9
Expand Down Expand Up @@ -2541,12 +2523,6 @@ workflows:
filters: *ref_9
requires:
- auth_3-amplify_e2e_tests
- api_4-amplify_e2e_tests:
context: *ref_7
post-steps: *ref_8
filters: *ref_9
requires:
- auth_1-amplify_e2e_tests
- schema-iterative-update-4-amplify_e2e_tests_pkg_linux:
context: &ref_10
- amplify-ecr-image-pull
Expand Down Expand Up @@ -2869,7 +2845,7 @@ workflows:
filters: *ref_12
requires:
- migration-api-key-migration1-amplify_e2e_tests_pkg_linux
- defer-init-push-amplify_e2e_tests_pkg_linux:
- configure-project-amplify_e2e_tests_pkg_linux:
context: *ref_10
post-steps: *ref_11
filters: *ref_12
Expand Down Expand Up @@ -2933,7 +2909,7 @@ workflows:
filters: *ref_12
requires:
- layer-amplify_e2e_tests_pkg_linux
- configure-project-amplify_e2e_tests_pkg_linux:
- api_4-amplify_e2e_tests_pkg_linux:
context: *ref_10
post-steps: *ref_11
filters: *ref_12
Expand Down Expand Up @@ -2997,9 +2973,3 @@ workflows:
filters: *ref_12
requires:
- auth_3-amplify_e2e_tests_pkg_linux
- api_4-amplify_e2e_tests_pkg_linux:
context: *ref_10
post-steps: *ref_11
filters: *ref_12
requires:
- auth_1-amplify_e2e_tests_pkg_linux
3 changes: 1 addition & 2 deletions packages/amplify-cli-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ interface AmplifyToolkit {
getProjectMeta: () => $TSMeta;
getResourceStatus: (category?: $TSAny, resourceName?: $TSAny, providerName?: $TSAny, filteredResources?: $TSAny) => $TSAny;
getResourceOutputs: () => $TSAny;
getTags: (context: $TSContext) => $TSAny;
getWhen: () => $TSAny;
inputValidation: (input: $TSAny) => $TSAny;
listCategories: () => $TSAny;
Expand All @@ -196,7 +195,7 @@ interface AmplifyToolkit {
filteredResources?: { category: string; resourceName: string }[],
) => $TSAny;
storeCurrentCloudBackend: () => $TSAny;
readJsonFile: (file: string) => $TSAny;
readJsonFile: () => $TSAny;
removeEnvFromCloud: () => $TSAny;
removeDeploymentSecrets: (context: $TSContext, category: string, resource: string) => void;
removeResource: () => $TSAny;
Expand Down
2 changes: 0 additions & 2 deletions packages/amplify-cli/src/commands/push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import sequential from 'promise-sequential';
import ora from 'ora';
import { $TSContext, $TSObject, stateManager, exitOnNextTick } from 'amplify-cli-core';
import { getProviderPlugins } from '../extensions/amplify-helpers/get-provider-plugins';
import { onSuccess } from '../init-steps/s9-onSuccess';

const spinner = ora('');

Expand Down Expand Up @@ -45,7 +44,6 @@ export const run = async (context: $TSContext) => {
if (context.parameters.options.force) {
context.exeInfo.forcePush = true;
}
context.exeInfo.deferredInitCallback = onSuccess;
await syncCurrentCloudBackend(context);
return await context.amplify.pushResources(context);
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,7 @@ export function saveEnvResourceParameters(context: $TSContext, category: string,
stateManager.setTeamProviderInfo(undefined, teamProviderInfo);
// write hostedUIProviderCreds to deploymentSecrets
const deploymentSecrets = stateManager.getDeploymentSecrets();
let rootStackId;
try {
rootStackId = getRootStackId();
} catch (err) {
return;
}
const rootStackId = getRootStackId();
if (hostedUIProviderCreds) {
stateManager.setDeploymentSecrets(
mergeDeploymentSecrets({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export function getRootStackId(): string {
const teamProviderInfo = stateManager.getTeamProviderInfo();
const { envName } = stateManager.getLocalEnvInfo();
const envTeamProviderInfo = teamProviderInfo[envName];
const stackId = envTeamProviderInfo?.awscloudformation?.StackId;
if (typeof stackId === 'string') {
if (envTeamProviderInfo && envTeamProviderInfo.awscloudformation) {
const stackId = envTeamProviderInfo.awscloudformation.StackId;
return stackId.split('/')[2];
}
throw new Error('Root stack Id not found');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,16 +486,12 @@ export async function showResourceTable(category, resourceName, filteredResource

table(tableOptions, { format: 'markdown' });

// in the case of a deferred init, need to also check there are resources in the project
// checking for length > 1 because for some reason the aws cfn provider is in the resources list but it's not a resource
const updateTags = tagsUpdated && allResources.length > 1;

if (updateTags) {
if (tagsUpdated) {
print.info('\nTag Changes Detected');
}

const resourceChanged =
resourcesToBeCreated.length + resourcesToBeUpdated.length + resourcesToBeSynced.length + resourcesToBeDeleted.length > 0 || updateTags;
resourcesToBeCreated.length + resourcesToBeUpdated.length + resourcesToBeSynced.length + resourcesToBeDeleted.length > 0 || tagsUpdated;

return resourceChanged;
}
18 changes: 5 additions & 13 deletions packages/amplify-cli/src/init-steps/s9-onSuccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getProviderPlugins } from '../extensions/amplify-helpers/get-provider-p
import { insertAmplifyIgnore } from '../extensions/amplify-helpers/git-manager';
import { writeReadMeFile } from '../extensions/amplify-helpers/docs-manager';
import { initializeEnv } from '../initialize-env';
import _ from 'lodash';

export async function onHeadlessSuccess(context: $TSContext) {
const frontendPlugins = getFrontendPlugins(context);
Expand Down Expand Up @@ -109,19 +108,12 @@ function generateLocalTagsFile(context: $TSContext) {
}

export function generateAmplifyMetaFile(context: $TSContext) {
const { projectPath } = context.exeInfo.localEnvInfo;

const { isNewEnv } = context.exeInfo;

// store amplifyMeta
const meta = isNewEnv ? {} : stateManager.getMeta(projectPath, { throwIfNotExist: false }) || {};
_.merge(meta, context.exeInfo.amplifyMeta);
stateManager.setMeta(projectPath, meta);
if (context.exeInfo.isNewEnv) {
const { projectPath } = context.exeInfo.localEnvInfo;

// store current cloud meta
const currMeta = isNewEnv ? {} : stateManager.getCurrentMeta(projectPath, { throwIfNotExist: false }) || {};
_.merge(currMeta, context.exeInfo.amplifyMeta);
stateManager.setCurrentMeta(projectPath, currMeta);
stateManager.setCurrentMeta(projectPath, context.exeInfo.amplifyMeta);
stateManager.setMeta(projectPath, context.exeInfo.amplifyMeta);
}
}

function generateNonRuntimeFiles(context: $TSContext) {
Expand Down
6 changes: 0 additions & 6 deletions packages/amplify-cli/src/initialize-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ export async function initializeEnv(context: $TSContext, currentAmplifyMeta?: $T

await sequential(categoryInitializationTasks);

// this function can now be called on the push codepath in the case of a deffered root stack push
// in that case, we don't need to push here as that will happen automatically down the road
if (context?.input?.command === 'push') {
return;
}

if (context.exeInfo.forcePush === undefined) {
context.exeInfo.forcePush = await context.amplify.confirmPrompt(
'Do you want to push your resources to the cloud for your environment?',
Expand Down
3 changes: 0 additions & 3 deletions packages/amplify-e2e-core/src/init/deleteProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { nspawn as spawn, retry, getCLIPath, describeCloudFormationStack, getPro

export const deleteProject = async (cwd: string, profileConfig?: any): Promise<void> => {
const { StackName: stackName, Region: region } = getProjectMeta(cwd).providers.awscloudformation;
if (!stackName || !region) {
return;
}
await retry(
() => describeCloudFormationStack(stackName, region, profileConfig),
stack => stack.StackStatus.endsWith('_COMPLETE'),
Expand Down
12 changes: 0 additions & 12 deletions packages/amplify-e2e-core/src/init/initProjectHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,6 @@ export function amplifyInitSandbox(cwd: string, settings: {}): Promise<void> {
});
}

export function amplifyInitYes(cwd: string): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(), ['init', '--yes'], {
cwd,
stripColors: true,
env: {
CLI_DEV_INTERNAL_DISABLE_AMPLIFY_APP_CREATION: '1',
},
}).run((err: Error) => (err ? reject(err) : resolve()));
});
}

export function amplifyVersion(cwd: string, expectedVersion: string, testingWithLatestCodebase = false): Promise<void> {
return new Promise((resolve, reject) => {
spawn(getCLIPath(testingWithLatestCodebase), ['--version'], { cwd, stripColors: true })
Expand Down
81 changes: 0 additions & 81 deletions packages/amplify-e2e-tests/src/__tests__/defer-init-push.test.ts

This file was deleted.

Loading

0 comments on commit 28b6a21

Please sign in to comment.