From 617bdbd95cdcfee410f80fbfad0558bee0886e48 Mon Sep 17 00:00:00 2001 From: AmmarKarachi Date: Thu, 18 Mar 2021 21:34:14 -0700 Subject: [PATCH] fix: fix s3Cloudfront exception on push --- .circleci/config.yml | 70 +++++++++---------- .../amplify-helpers/resource-status.ts | 56 +++++++-------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 44833a03ffa..75e62493884 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,11 +4,11 @@ orbs: aws-ecr: circleci/aws-ecr@6.15.3 machine: environment: - PATH: '${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin' -node12: + PATH: ${PATH}:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin +node10: working_directory: ~/repo docker: &ref_0 - - image: 'circleci/node:10' + - image: circleci/node:10 auth: username: $DOCKERHUB_USERNAME password: $DOCKERHUB_ACCESS_TOKEN @@ -16,7 +16,7 @@ node12: defaults: working_directory: ~/repo docker: &ref_1 - - image: '${AWS_ECR_ACCOUNT_URL}/amplify-cli-e2e-base-image-repo:latest' + - image: ${AWS_ECR_ACCOUNT_URL}/amplify-cli-e2e-base-image-repo:latest aws_auth: aws_access_key_id: $ECR_ACCESS_KEY aws_secret_access_key: $ECR_SECRET_ACCESS_KEY @@ -42,7 +42,7 @@ run_e2e_tests: &ref_3 unsetNpmRegistryUrl no_output_timeout: 90m install_cli_from_local_registery: &ref_2 - name: 'Start verdaccio, install node CLI and amplify-app' + name: Start verdaccio, install node CLI and amplify-app command: | source .circleci/local_publish_helpers.sh startLocalRegistry "$(pwd)/.circleci/verdaccio.yaml" @@ -60,11 +60,11 @@ jobs: - checkout - run: yarn run production-build - save_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} paths: - ~/.cache - save_cache: - key: 'amplify-cli-ssh-deps-{{ .Branch }}' + key: amplify-cli-ssh-deps-{{ .Branch }} paths: - ~/.ssh - persist_to_workspace: @@ -78,7 +78,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Install Java command: sudo apt-get install default-jdk @@ -99,7 +99,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Install Java command: sudo apt-get install default-jdk @@ -119,7 +119,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Publish to verdaccio command: | @@ -141,15 +141,15 @@ jobs: name: Save new amplify GitHub tag command: node scripts/echo-current-cli-version.js > .amplify-pkg-version - save_cache: - key: 'amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}' + key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }} paths: - ~/verdaccio-cache/ - save_cache: - key: 'amplify-unified-changelog-{{ .Branch }}-{{ .Revision }}' + key: amplify-unified-changelog-{{ .Branch }}-{{ .Revision }} paths: - ~/repo/UNIFIED_CHANGELOG.md - save_cache: - key: 'amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}' + key: amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }} paths: - ~/repo/.amplify-pkg-version build_pkg_binaries: @@ -160,9 +160,9 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - restore_cache: - key: 'amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}' + key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }} - run: name: Start verdaccio and package CLI command: | @@ -173,7 +173,7 @@ jobs: yarn pkg-all unsetNpmRegistryUrl - save_cache: - key: 'amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}' + key: amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }} paths: - ~/repo/out graphql_e2e_tests: @@ -184,7 +184,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Run GraphQL end-to-end tests command: >- @@ -201,7 +201,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}' + key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }} - run: name: Update OS Packages command: sudo apt-get update @@ -223,7 +223,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}' + key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }} - run: *ref_2 - run: *ref_3 - store_test_results: @@ -253,9 +253,9 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - restore_cache: - key: 'amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}' + key: amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }} - run: name: Symlink Amplify packaged CLI command: | @@ -278,7 +278,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Run tests migrating from CLI v4.0.0 command: | @@ -301,7 +301,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Update OS Packages command: sudo apt-get update @@ -325,7 +325,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }}' + key: amplify-cli-yarn-deps-{{ .Branch }}-{{ checksum "yarn.lock" }} - run: name: Run tests migrating from latest CLI command: | @@ -346,7 +346,7 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }}' + key: amplify-verdaccio-cache-{{ .Branch }}-{{ .Revision }} - run: *ref_2 - run: command: | @@ -365,7 +365,7 @@ jobs: integration_test: working_directory: ~/repo docker: - - image: 'cypress/base:10.18.0' + - image: cypress/base:10.18.0 environment: TERM: dumb resource_class: large @@ -423,7 +423,7 @@ jobs: node_modules/.bin/cypress run --spec $(find . -type f -name 'auth_spec*') - - run: 'sudo kill -9 $(lsof -t -i:3000)' + - run: sudo kill -9 $(lsof -t -i:3000) - run: cd .circleci/ && chmod +x delete_auth.sh - run: expect .circleci/delete_auth.exp - run: @@ -480,10 +480,10 @@ jobs: at: ./ - restore_cache: keys: - - 'amplify-cli-ssh-deps-{{ .Branch }}' + - amplify-cli-ssh-deps-{{ .Branch }} - run: name: Authenticate with npm - command: 'echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc' + command: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc - run: name: Publish Amplify CLI command: | @@ -502,11 +502,11 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-unified-changelog-{{ .Branch }}-{{ .Revision }}' + key: amplify-unified-changelog-{{ .Branch }}-{{ .Revision }} - restore_cache: - key: 'amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}' + key: amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }} - restore_cache: - key: 'amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}' + key: amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }} - run: name: Compress binaries command: | @@ -525,7 +525,7 @@ jobs: resource_class: large steps: - restore_cache: - key: 'amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}' + key: amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }} - run: name: Install packaged Amplify CLI command: > @@ -547,9 +547,9 @@ jobs: - attach_workspace: at: ./ - restore_cache: - key: 'amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }}' + key: amplify-pkg-binaries-{{ .Branch }}-{{ .Revision }} - restore_cache: - key: 'amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }}' + key: amplfiy-pkg-tag-{{ .Branch }}-{{ .Revision }} - run: name: Publish Amplify CLI GitHub release command: | diff --git a/packages/amplify-cli/src/extensions/amplify-helpers/resource-status.ts b/packages/amplify-cli/src/extensions/amplify-helpers/resource-status.ts index f1d0824a088..4a7c71ca6db 100644 --- a/packages/amplify-cli/src/extensions/amplify-helpers/resource-status.ts +++ b/packages/amplify-cli/src/extensions/amplify-helpers/resource-status.ts @@ -188,34 +188,6 @@ async function getResourcesToBeUpdated(amplifyMeta, currentAmplifyMeta, category removeGetUserEndpoints(resource); } - if (categoryName === 'hosting' && currentAmplifyMeta[categoryName][resource].service === 'ElasticContainer') { - const { - frontend, - [frontend]: { - config: { SourceDir }, - }, - } = stateManager.getProjectConfig(); - // build absolute path for Dockerfile and docker-compose.yaml - const projectRootPath = pathManager.findProjectRoot(); - if (projectRootPath) { - const sourceAbsolutePath = path.join(projectRootPath, SourceDir); - - // Generate the hash for this file, cfn files are autogenerated based on Dockerfile and resource settings - // Hash is generated by this files and not cfn files - const dockerfileHash = await getHashForResourceDir(sourceAbsolutePath, [ - 'Dockerfile', - 'docker-compose.yaml', - 'docker-compose.yml', - ]); - - // Compare hash with value stored on meta - if (currentAmplifyMeta[categoryName][resource]['lastPushDirHash'] !== dockerfileHash) { - resources.push(amplifyMeta[categoryName][resource]); - return; - } - } - } - if ( currentAmplifyMeta[categoryName] && currentAmplifyMeta[categoryName][resource] !== undefined && @@ -236,6 +208,34 @@ async function getResourcesToBeUpdated(amplifyMeta, currentAmplifyMeta, category amplifyMeta[categoryName][resource].category = categoryName; resources.push(amplifyMeta[categoryName][resource]); } + + if (categoryName === 'hosting' && currentAmplifyMeta[categoryName][resource].service === 'ElasticContainer') { + const { + frontend, + [frontend]: { + config: { SourceDir }, + }, + } = stateManager.getProjectConfig(); + // build absolute path for Dockerfile and docker-compose.yaml + const projectRootPath = pathManager.findProjectRoot(); + if (projectRootPath) { + const sourceAbsolutePath = path.join(projectRootPath, SourceDir); + + // Generate the hash for this file, cfn files are autogenerated based on Dockerfile and resource settings + // Hash is generated by this files and not cfn files + const dockerfileHash = await getHashForResourceDir(sourceAbsolutePath, [ + 'Dockerfile', + 'docker-compose.yaml', + 'docker-compose.yml', + ]); + + // Compare hash with value stored on meta + if (currentAmplifyMeta[categoryName][resource]['lastPushDirHash'] !== dockerfileHash) { + resources.push(amplifyMeta[categoryName][resource]); + return; + } + } + } } }); });