From 0c0adfb78350a192d4f44b722d6038b23c505527 Mon Sep 17 00:00:00 2001 From: David Lopez Date: Wed, 7 Jul 2021 09:19:47 -0700 Subject: [PATCH 001/125] fix(amplify-category-auth): check for siwa Cognito idp params (#7678) Need to check for siwa params because privateKey is not returned from Cognito, so it may not always be available. Worst case the user will need to re-configure SIWA in a new environment for amplify init. Co-authored-by: David Lopez --- .../auth-template.yml.ejs | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs b/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs index a6b89c10c56..e3f31d0b3e1 100644 --- a/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs +++ b/packages/amplify-category-auth/resources/cloudformation-templates/auth-template.yml.ejs @@ -594,13 +594,17 @@ Resources: - ' AttributeMapping: providerMeta.AttributeMapping,' - ' };' - ' if (providerMeta.ProviderName === ''SignInWithApple'') {' - - ' requestParams.ProviderDetails = {' - - ' ''client_id'': providerCreds.client_id,' - - ' ''team_id'': providerCreds.team_id,' - - ' ''key_id'': providerCreds.key_id,' - - ' ''private_key'': providerCreds.private_key,' - - ' ''authorize_scopes'': providerMeta.authorize_scopes,' - - ' };' + - ' if (providerCreds.client_id && providerCreds.team_id && providerCreds.key_id && providerCreds.private_key) {' + - ' requestParams.ProviderDetails = {' + - ' ''client_id'': providerCreds.client_id,' + - ' ''team_id'': providerCreds.team_id,' + - ' ''key_id'': providerCreds.key_id,' + - ' ''private_key'': providerCreds.private_key,' + - ' ''authorize_scopes'': providerMeta.authorize_scopes,' + - ' };' + - ' } else {' + - ' requestParams = null;' + - ' }' - ' } else {' - ' requestParams.ProviderDetails = {' - ' ''client_id'': providerCreds.client_id,' @@ -612,11 +616,17 @@ Resources: - ' };' - ' let createIdentityProvider = (providerName) => {' - ' let requestParams = getRequestParams(providerName);' + - ' if (!requestParams) {' + - ' return Promise.resolve();' + - ' }' - ' requestParams.ProviderType = requestParams.ProviderName;' - ' return identity.createIdentityProvider(requestParams).promise();' - ' };' - ' let updateIdentityProvider = (providerName) => {' - ' let requestParams = getRequestParams(providerName);' + - ' if (!requestParams) {' + - ' return Promise.resolve();' + - ' }' - ' return identity.updateIdentityProvider(requestParams).promise();' - ' };' - ' let deleteIdentityProvider = (providerName) => {' From 753a7379c2600988a7b68b9c9f5e2cc6b1bf2fb4 Mon Sep 17 00:00:00 2001 From: aws-amplify-bot Date: Mon, 12 Jul 2021 16:47:37 +0000 Subject: [PATCH 002/125] chore(release): Publish [ci skip] - amplify-app@3.0.3 - amplify-appsync-simulator@1.27.2 - amplify-category-api@2.31.14 - amplify-category-auth@2.35.0 - @aws-amplify/cli@5.1.1 - amplify-console-integration-tests@1.8.0 - amplify-container-hosting@1.3.14 - amplify-e2e-core@1.23.0 - amplify-e2e-tests@2.45.0 - amplify-frontend-javascript@2.23.0 - amplify-go-function-runtime-provider@1.8.6 - @aws-amplify/graphql-function-transformer@0.3.5 - @aws-amplify/graphql-http-transformer@0.4.1 - @aws-amplify/graphql-model-transformer@0.4.4 - @aws-amplify/graphql-predictions-transformer@0.2.0 - @aws-amplify/graphql-searchable-transformer@0.3.0 - @aws-amplify/graphql-transformer-core@0.7.0 - @aws-amplify/graphql-transformer-interfaces@1.7.0 - amplify-headless-interface@1.8.0 - amplify-migration-tests@3.1.0 - amplify-provider-awscloudformation@4.55.0 - amplify-util-headless-input@1.5.1 - amplify-util-mock@3.33.4 --- packages/amplify-app/CHANGELOG.md | 8 ++++++++ packages/amplify-app/package.json | 4 ++-- .../amplify-appsync-simulator/CHANGELOG.md | 11 ++++++++++ .../amplify-appsync-simulator/package.json | 2 +- packages/amplify-category-api/CHANGELOG.md | 8 ++++++++ packages/amplify-category-api/package.json | 4 ++-- packages/amplify-category-auth/CHANGELOG.md | 20 +++++++++++++++++++ packages/amplify-category-auth/package.json | 6 +++--- packages/amplify-cli/CHANGELOG.md | 8 ++++++++ packages/amplify-cli/package.json | 18 ++++++++--------- .../CHANGELOG.md | 11 ++++++++++ .../package.json | 4 ++-- .../amplify-container-hosting/CHANGELOG.md | 8 ++++++++ .../amplify-container-hosting/package.json | 4 ++-- packages/amplify-e2e-core/CHANGELOG.md | 11 ++++++++++ packages/amplify-e2e-core/package.json | 4 ++-- packages/amplify-e2e-tests/CHANGELOG.md | 11 ++++++++++ packages/amplify-e2e-tests/package.json | 4 ++-- .../amplify-frontend-javascript/CHANGELOG.md | 11 ++++++++++ .../amplify-frontend-javascript/package.json | 2 +- .../CHANGELOG.md | 11 ++++++++++ .../package.json | 2 +- .../CHANGELOG.md | 8 ++++++++ .../package.json | 6 +++--- .../CHANGELOG.md | 8 ++++++++ .../package.json | 6 +++--- .../CHANGELOG.md | 11 ++++++++++ .../package.json | 6 +++--- .../CHANGELOG.md | 7 +++++++ .../package.json | 8 ++++---- .../CHANGELOG.md | 18 +++++++++++++++++ .../package.json | 6 +++--- .../CHANGELOG.md | 11 ++++++++++ .../package.json | 4 ++-- .../CHANGELOG.md | 11 ++++++++++ .../package.json | 2 +- .../amplify-headless-interface/CHANGELOG.md | 11 ++++++++++ .../amplify-headless-interface/package.json | 2 +- packages/amplify-migration-tests/CHANGELOG.md | 11 ++++++++++ packages/amplify-migration-tests/package.json | 4 ++-- .../CHANGELOG.md | 11 ++++++++++ .../package.json | 16 +++++++-------- .../amplify-util-headless-input/CHANGELOG.md | 8 ++++++++ .../amplify-util-headless-input/package.json | 4 ++-- packages/amplify-util-mock/CHANGELOG.md | 8 ++++++++ packages/amplify-util-mock/package.json | 6 +++--- 46 files changed, 303 insertions(+), 62 deletions(-) diff --git a/packages/amplify-app/CHANGELOG.md b/packages/amplify-app/CHANGELOG.md index 71a5acc83cd..f2b89c2b282 100644 --- a/packages/amplify-app/CHANGELOG.md +++ b/packages/amplify-app/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.0.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-app@3.0.2...amplify-app@3.0.3) (2021-07-12) + +**Note:** Version bump only for package amplify-app + + + + + ## [3.0.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-app@3.0.1...amplify-app@3.0.2) (2021-06-30) **Note:** Version bump only for package amplify-app diff --git a/packages/amplify-app/package.json b/packages/amplify-app/package.json index ae47a475144..7550f57f831 100644 --- a/packages/amplify-app/package.json +++ b/packages/amplify-app/package.json @@ -1,6 +1,6 @@ { "name": "amplify-app", - "version": "3.0.2", + "version": "3.0.3", "description": "Amplify CLI", "repository": { "type": "git", @@ -31,7 +31,7 @@ "amplify-frontend-android": "2.15.3", "amplify-frontend-flutter": "0.4.3", "amplify-frontend-ios": "2.20.5", - "amplify-frontend-javascript": "2.22.5", + "amplify-frontend-javascript": "2.23.0", "chalk": "^3.0.0", "execa": "^4.1.0", "fs-extra": "^8.1.0", diff --git a/packages/amplify-appsync-simulator/CHANGELOG.md b/packages/amplify-appsync-simulator/CHANGELOG.md index 268cd07287c..8a76a5e53d1 100644 --- a/packages/amplify-appsync-simulator/CHANGELOG.md +++ b/packages/amplify-appsync-simulator/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.27.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-appsync-simulator@1.27.1...amplify-appsync-simulator@1.27.2) (2021-07-12) + + +### Bug Fixes + +* get mock working with gql transformer v2 ([#7574](https://github.com/aws-amplify/amplify-cli/issues/7574)) ([4fa2900](https://github.com/aws-amplify/amplify-cli/commit/4fa2900d6b9ca515677d06bdffe29f56401b9c86)) + + + + + ## [1.27.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-appsync-simulator@1.27.0...amplify-appsync-simulator@1.27.1) (2021-06-24) diff --git a/packages/amplify-appsync-simulator/package.json b/packages/amplify-appsync-simulator/package.json index 6a8d2991308..6e5b8bea9cd 100644 --- a/packages/amplify-appsync-simulator/package.json +++ b/packages/amplify-appsync-simulator/package.json @@ -1,6 +1,6 @@ { "name": "amplify-appsync-simulator", - "version": "1.27.1", + "version": "1.27.2", "description": "An AppSync Simulator to test AppSync API.", "repository": { "type": "git", diff --git a/packages/amplify-category-api/CHANGELOG.md b/packages/amplify-category-api/CHANGELOG.md index 6495b3e09bf..013c6d1e053 100644 --- a/packages/amplify-category-api/CHANGELOG.md +++ b/packages/amplify-category-api/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.31.14](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-api@2.31.13...amplify-category-api@2.31.14) (2021-07-12) + +**Note:** Version bump only for package amplify-category-api + + + + + ## [2.31.13](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-api@2.31.12...amplify-category-api@2.31.13) (2021-06-30) diff --git a/packages/amplify-category-api/package.json b/packages/amplify-category-api/package.json index c5224f6f779..b553bb4f010 100644 --- a/packages/amplify-category-api/package.json +++ b/packages/amplify-category-api/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-api", - "version": "2.31.13", + "version": "2.31.14", "description": "amplify-cli api plugin", "repository": { "type": "git", @@ -63,7 +63,7 @@ "@aws-cdk/region-info": "~1.72.0", "@graphql-tools/merge": "^6.0.18", "amplify-cli-core": "1.24.0", - "amplify-util-headless-input": "1.5.0", + "amplify-util-headless-input": "1.5.1", "chalk": "^3.0.0", "constructs": "^3.2.0", "fs-extra": "^8.1.0", diff --git a/packages/amplify-category-auth/CHANGELOG.md b/packages/amplify-category-auth/CHANGELOG.md index e9ca77d781f..9a2d1a19a9d 100644 --- a/packages/amplify-category-auth/CHANGELOG.md +++ b/packages/amplify-category-auth/CHANGELOG.md @@ -3,6 +3,26 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.35.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-auth@2.34.1...amplify-category-auth@2.35.0) (2021-07-12) + + + +## 5.1.1 (2021-07-07) + + +### Bug Fixes + +* **amplify-category-auth:** check for siwa Cognito idp params ([#7678](https://github.com/aws-amplify/amplify-cli/issues/7678)) ([0c0adfb](https://github.com/aws-amplify/amplify-cli/commit/0c0adfb78350a192d4f44b722d6038b23c505527)) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-cli/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-cli/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + ## [2.34.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-category-auth@2.34.0...amplify-category-auth@2.34.1) (2021-06-30) **Note:** Version bump only for package amplify-category-auth diff --git a/packages/amplify-category-auth/package.json b/packages/amplify-category-auth/package.json index 55f10a816a9..ac117c59c07 100644 --- a/packages/amplify-category-auth/package.json +++ b/packages/amplify-category-auth/package.json @@ -1,6 +1,6 @@ { "name": "amplify-category-auth", - "version": "2.34.1", + "version": "2.35.0", "description": "amplify-cli authentication plugin", "repository": { "type": "git", @@ -24,8 +24,8 @@ }, "dependencies": { "amplify-cli-core": "1.24.0", - "amplify-headless-interface": "1.7.0", - "amplify-util-headless-input": "1.5.0", + "amplify-headless-interface": "1.8.0", + "amplify-util-headless-input": "1.5.1", "amplify-util-import": "1.5.3", "aws-cdk": "~1.72.0", "aws-sdk": "^2.919.0", diff --git a/packages/amplify-cli/CHANGELOG.md b/packages/amplify-cli/CHANGELOG.md index 0519c58624e..222c17cbf7f 100644 --- a/packages/amplify-cli/CHANGELOG.md +++ b/packages/amplify-cli/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [5.1.1](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/cli@5.1.0...@aws-amplify/cli@5.1.1) (2021-07-12) + +**Note:** Version bump only for package @aws-amplify/cli + + + + + # [5.1.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/cli@5.0.2...@aws-amplify/cli@5.1.0) (2021-06-30) diff --git a/packages/amplify-cli/package.json b/packages/amplify-cli/package.json index d9640534b5c..64b7675f04f 100644 --- a/packages/amplify-cli/package.json +++ b/packages/amplify-cli/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/cli", - "version": "5.1.0", + "version": "5.1.1", "description": "Amplify CLI", "repository": { "type": "git", @@ -33,10 +33,10 @@ "node": ">=12.0.0" }, "dependencies": { - "amplify-app": "3.0.2", + "amplify-app": "3.0.3", "amplify-category-analytics": "2.21.12", - "amplify-category-api": "2.31.13", - "amplify-category-auth": "2.34.1", + "amplify-category-api": "2.31.14", + "amplify-category-auth": "2.35.0", "amplify-category-function": "2.33.0", "amplify-category-hosting": "2.7.12", "amplify-category-interactions": "2.6.2", @@ -48,24 +48,24 @@ "amplify-cli-logger": "1.1.0", "amplify-codegen": "^2.23.1", "amplify-console-hosting": "1.9.3", - "amplify-container-hosting": "1.3.13", + "amplify-container-hosting": "1.3.14", "amplify-dotnet-function-runtime-provider": "1.6.1", "amplify-dotnet-function-template-provider": "1.5.12", "amplify-frontend-android": "2.15.3", "amplify-frontend-flutter": "0.4.3", "amplify-frontend-ios": "2.20.5", - "amplify-frontend-javascript": "2.22.5", - "amplify-go-function-runtime-provider": "1.8.5", + "amplify-frontend-javascript": "2.23.0", + "amplify-go-function-runtime-provider": "1.8.6", "amplify-go-function-template-provider": "1.3.9", "amplify-java-function-runtime-provider": "1.8.5", "amplify-java-function-template-provider": "1.5.8", "amplify-nodejs-function-runtime-provider": "1.6.2", "amplify-nodejs-function-template-provider": "1.6.12", - "amplify-provider-awscloudformation": "4.54.0", + "amplify-provider-awscloudformation": "4.55.0", "amplify-python-function-runtime-provider": "1.9.2", "amplify-python-function-template-provider": "1.3.11", "amplify-util-import": "1.5.3", - "amplify-util-mock": "3.33.3", + "amplify-util-mock": "3.33.4", "aws-sdk": "^2.919.0", "chalk": "^3.0.0", "ci-info": "^2.0.0", diff --git a/packages/amplify-console-integration-tests/CHANGELOG.md b/packages/amplify-console-integration-tests/CHANGELOG.md index 00d5e4a615a..4ef4fa81de0 100644 --- a/packages/amplify-console-integration-tests/CHANGELOG.md +++ b/packages/amplify-console-integration-tests/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.8.0](https://github.com/aws-amplify/amplify-console-integration-tests/compare/amplify-console-integration-tests@1.7.3...amplify-console-integration-tests@1.8.0) (2021-07-12) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-console-integration-tests/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-console-integration-tests/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + ## [1.7.3](https://github.com/aws-amplify/amplify-console-integration-tests/compare/amplify-console-integration-tests@1.7.2...amplify-console-integration-tests@1.7.3) (2021-06-30) **Note:** Version bump only for package amplify-console-integration-tests diff --git a/packages/amplify-console-integration-tests/package.json b/packages/amplify-console-integration-tests/package.json index c3a52817304..38c21967e41 100644 --- a/packages/amplify-console-integration-tests/package.json +++ b/packages/amplify-console-integration-tests/package.json @@ -1,6 +1,6 @@ { "name": "amplify-console-integration-tests", - "version": "1.7.3", + "version": "1.8.0", "description": "", "repository": { "type": "git", @@ -22,7 +22,7 @@ }, "dependencies": { "@types/ini": "^1.3.30", - "amplify-e2e-core": "1.22.0", + "amplify-e2e-core": "1.23.0", "aws-sdk": "^2.919.0", "dotenv": "^8.2.0", "esm": "^3.2.25", diff --git a/packages/amplify-container-hosting/CHANGELOG.md b/packages/amplify-container-hosting/CHANGELOG.md index ecca5a26277..69670fea6cd 100644 --- a/packages/amplify-container-hosting/CHANGELOG.md +++ b/packages/amplify-container-hosting/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.3.14](https://github.com/aws-amplify/amplify-cli/compare/amplify-container-hosting@1.3.13...amplify-container-hosting@1.3.14) (2021-07-12) + +**Note:** Version bump only for package amplify-container-hosting + + + + + ## [1.3.13](https://github.com/aws-amplify/amplify-cli/compare/amplify-container-hosting@1.3.12...amplify-container-hosting@1.3.13) (2021-06-30) **Note:** Version bump only for package amplify-container-hosting diff --git a/packages/amplify-container-hosting/package.json b/packages/amplify-container-hosting/package.json index c856e2ae5a0..56b6b4a4596 100644 --- a/packages/amplify-container-hosting/package.json +++ b/packages/amplify-container-hosting/package.json @@ -1,6 +1,6 @@ { "name": "amplify-container-hosting", - "version": "1.3.13", + "version": "1.3.14", "description": "amplify-cli hosting plugin for containers", "repository": { "type": "git", @@ -18,7 +18,7 @@ "test": "jest --coverage --passWithNoTests" }, "dependencies": { - "amplify-category-api": "2.31.13", + "amplify-category-api": "2.31.14", "chalk": "^3.0.0", "fs-extra": "^8.1.0", "inquirer": "^7.3.3", diff --git a/packages/amplify-e2e-core/CHANGELOG.md b/packages/amplify-e2e-core/CHANGELOG.md index c0cffffe842..093ee1d8e69 100644 --- a/packages/amplify-e2e-core/CHANGELOG.md +++ b/packages/amplify-e2e-core/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.23.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-core@1.22.0...amplify-e2e-core@1.23.0) (2021-07-12) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-cli/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-cli/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + # [1.22.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-core@1.21.0...amplify-e2e-core@1.22.0) (2021-06-30) diff --git a/packages/amplify-e2e-core/package.json b/packages/amplify-e2e-core/package.json index 78308919cc9..1752da2dc68 100644 --- a/packages/amplify-e2e-core/package.json +++ b/packages/amplify-e2e-core/package.json @@ -1,6 +1,6 @@ { "name": "amplify-e2e-core", - "version": "1.22.0", + "version": "1.23.0", "description": "", "repository": { "type": "git", @@ -23,7 +23,7 @@ }, "dependencies": { "amplify-cli-core": "1.24.0", - "amplify-headless-interface": "1.7.0", + "amplify-headless-interface": "1.8.0", "chalk": "^3.0.0", "execa": "^4.1.0", "fs-extra": "^8.1.0", diff --git a/packages/amplify-e2e-tests/CHANGELOG.md b/packages/amplify-e2e-tests/CHANGELOG.md index a47e799b9f6..311302465c7 100644 --- a/packages/amplify-e2e-tests/CHANGELOG.md +++ b/packages/amplify-e2e-tests/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.45.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-tests@2.44.0...amplify-e2e-tests@2.45.0) (2021-07-12) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-cli/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-cli/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + # [2.44.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-e2e-tests@2.43.0...amplify-e2e-tests@2.44.0) (2021-06-30) diff --git a/packages/amplify-e2e-tests/package.json b/packages/amplify-e2e-tests/package.json index d20321cc68b..1c2664e7a46 100644 --- a/packages/amplify-e2e-tests/package.json +++ b/packages/amplify-e2e-tests/package.json @@ -1,6 +1,6 @@ { "name": "amplify-e2e-tests", - "version": "2.44.0", + "version": "2.45.0", "description": "", "repository": { "type": "git", @@ -24,7 +24,7 @@ }, "dependencies": { "amplify-cli-core": "1.24.0", - "amplify-e2e-core": "1.22.0", + "amplify-e2e-core": "1.23.0", "aws-amplify": "^3.0.8", "aws-appsync": "^4.0.3", "aws-sdk": "^2.919.0", diff --git a/packages/amplify-frontend-javascript/CHANGELOG.md b/packages/amplify-frontend-javascript/CHANGELOG.md index d2197523764..910485c75b2 100644 --- a/packages/amplify-frontend-javascript/CHANGELOG.md +++ b/packages/amplify-frontend-javascript/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [2.23.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-javascript@2.22.5...amplify-frontend-javascript@2.23.0) (2021-07-12) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-cli/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-cli/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + ## [2.22.5](https://github.com/aws-amplify/amplify-cli/compare/amplify-frontend-javascript@2.22.4...amplify-frontend-javascript@2.22.5) (2021-06-30) **Note:** Version bump only for package amplify-frontend-javascript diff --git a/packages/amplify-frontend-javascript/package.json b/packages/amplify-frontend-javascript/package.json index ef80fc7c5c6..8fde40d1e70 100644 --- a/packages/amplify-frontend-javascript/package.json +++ b/packages/amplify-frontend-javascript/package.json @@ -1,6 +1,6 @@ { "name": "amplify-frontend-javascript", - "version": "2.22.5", + "version": "2.23.0", "description": "amplify-cli front-end plugin for JavaScript projects", "repository": { "type": "git", diff --git a/packages/amplify-go-function-runtime-provider/CHANGELOG.md b/packages/amplify-go-function-runtime-provider/CHANGELOG.md index 0f3ed22c55c..5f93ab15949 100644 --- a/packages/amplify-go-function-runtime-provider/CHANGELOG.md +++ b/packages/amplify-go-function-runtime-provider/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.8.6](https://github.com/aws-amplify/amplify-cli/compare/amplify-go-function-runtime-provider@1.8.5...amplify-go-function-runtime-provider@1.8.6) (2021-07-12) + + +### Bug Fixes + +* **amplify-go-function-runtime-provider:** localinvoke build error with Go 1.16 ([#7621](https://github.com/aws-amplify/amplify-cli/issues/7621)) ([140a825](https://github.com/aws-amplify/amplify-cli/commit/140a8255a6e4d9faaf8af2bfa1db2302cea1cd23)) + + + + + ## [1.8.5](https://github.com/aws-amplify/amplify-cli/compare/amplify-go-function-runtime-provider@1.8.4...amplify-go-function-runtime-provider@1.8.5) (2021-06-30) **Note:** Version bump only for package amplify-go-function-runtime-provider diff --git a/packages/amplify-go-function-runtime-provider/package.json b/packages/amplify-go-function-runtime-provider/package.json index 9e9288a3389..490cc3bb168 100644 --- a/packages/amplify-go-function-runtime-provider/package.json +++ b/packages/amplify-go-function-runtime-provider/package.json @@ -1,6 +1,6 @@ { "name": "amplify-go-function-runtime-provider", - "version": "1.8.5", + "version": "1.8.6", "description": "Provides functionality related to functions in Go 1.x on AWS", "repository": { "type": "git", diff --git a/packages/amplify-graphql-function-transformer/CHANGELOG.md b/packages/amplify-graphql-function-transformer/CHANGELOG.md index 8883b173b49..294af5f1d07 100644 --- a/packages/amplify-graphql-function-transformer/CHANGELOG.md +++ b/packages/amplify-graphql-function-transformer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.3.5](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-function-transformer@0.3.4...@aws-amplify/graphql-function-transformer@0.3.5) (2021-07-12) + +**Note:** Version bump only for package @aws-amplify/graphql-function-transformer + + + + + ## [0.3.4](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-function-transformer@0.3.3...@aws-amplify/graphql-function-transformer@0.3.4) (2021-06-30) **Note:** Version bump only for package @aws-amplify/graphql-function-transformer diff --git a/packages/amplify-graphql-function-transformer/package.json b/packages/amplify-graphql-function-transformer/package.json index 69af924efe1..8a1b91a050a 100644 --- a/packages/amplify-graphql-function-transformer/package.json +++ b/packages/amplify-graphql-function-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-function-transformer", - "version": "0.3.4", + "version": "0.3.5", "description": "Amplify GraphQL @function transformer", "repository": { "type": "git", @@ -27,8 +27,8 @@ "test": "jest" }, "dependencies": { - "@aws-amplify/graphql-transformer-core": "0.6.3", - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-transformer-core": "0.7.0", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/aws-lambda": "~1.72.0", "@aws-cdk/core": "~1.72.0", "graphql": "^14.5.8", diff --git a/packages/amplify-graphql-http-transformer/CHANGELOG.md b/packages/amplify-graphql-http-transformer/CHANGELOG.md index 92725aba654..2fb16ea4d13 100644 --- a/packages/amplify-graphql-http-transformer/CHANGELOG.md +++ b/packages/amplify-graphql-http-transformer/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.1](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.4.0...@aws-amplify/graphql-http-transformer@0.4.1) (2021-07-12) + +**Note:** Version bump only for package @aws-amplify/graphql-http-transformer + + + + + # [0.4.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-http-transformer@0.3.3...@aws-amplify/graphql-http-transformer@0.4.0) (2021-06-30) diff --git a/packages/amplify-graphql-http-transformer/package.json b/packages/amplify-graphql-http-transformer/package.json index fe94a168b42..86b6807dc24 100644 --- a/packages/amplify-graphql-http-transformer/package.json +++ b/packages/amplify-graphql-http-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-http-transformer", - "version": "0.4.0", + "version": "0.4.1", "description": "Amplify GraphQL @http transformer", "repository": { "type": "git", @@ -27,8 +27,8 @@ "test": "jest" }, "dependencies": { - "@aws-amplify/graphql-transformer-core": "0.6.3", - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-transformer-core": "0.7.0", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/core": "~1.72.0", "graphql": "^14.5.8", "graphql-mapping-template": "4.18.1", diff --git a/packages/amplify-graphql-model-transformer/CHANGELOG.md b/packages/amplify-graphql-model-transformer/CHANGELOG.md index d8fa0718930..8bbfac41bae 100644 --- a/packages/amplify-graphql-model-transformer/CHANGELOG.md +++ b/packages/amplify-graphql-model-transformer/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.4.4](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-model-transformer@0.4.3...@aws-amplify/graphql-model-transformer@0.4.4) (2021-07-12) + + +### Bug Fixes + +* get mock working with gql transformer v2 ([#7574](https://github.com/aws-amplify/amplify-cli/issues/7574)) ([4fa2900](https://github.com/aws-amplify/amplify-cli/commit/4fa2900d6b9ca515677d06bdffe29f56401b9c86)) + + + + + ## [0.4.3](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-model-transformer@0.4.2...@aws-amplify/graphql-model-transformer@0.4.3) (2021-06-30) diff --git a/packages/amplify-graphql-model-transformer/package.json b/packages/amplify-graphql-model-transformer/package.json index d3887f35c36..b0883f61282 100644 --- a/packages/amplify-graphql-model-transformer/package.json +++ b/packages/amplify-graphql-model-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-model-transformer", - "version": "0.4.3", + "version": "0.4.4", "description": "Amplify graphql @model transformer", "repository": { "type": "git", @@ -26,8 +26,8 @@ "clean": "rimraf ./lib" }, "dependencies": { - "@aws-amplify/graphql-transformer-core": "0.6.3", - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-transformer-core": "0.7.0", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/assets": "~1.72.0", "@aws-cdk/aws-applicationautoscaling": "~1.72.0", "@aws-cdk/aws-autoscaling-common": "~1.72.0", diff --git a/packages/amplify-graphql-predictions-transformer/CHANGELOG.md b/packages/amplify-graphql-predictions-transformer/CHANGELOG.md index e4d87c4d45c..0bb64fe4a9e 100644 --- a/packages/amplify-graphql-predictions-transformer/CHANGELOG.md +++ b/packages/amplify-graphql-predictions-transformer/CHANGELOG.md @@ -2,3 +2,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# 0.2.0 (2021-07-12) + + +### Features + +* port [@predictions](https://github.com/predictions) to GraphQL Transformer v2 ([#7387](https://github.com/aws-amplify/amplify-cli/issues/7387)) ([3f2e647](https://github.com/aws-amplify/amplify-cli/commit/3f2e647b9dfe14aa5919b46f53342937dd0c7fa9)) diff --git a/packages/amplify-graphql-predictions-transformer/package.json b/packages/amplify-graphql-predictions-transformer/package.json index 07017d37834..80921de5133 100644 --- a/packages/amplify-graphql-predictions-transformer/package.json +++ b/packages/amplify-graphql-predictions-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-predictions-transformer", - "version": "0.1.0", + "version": "0.2.0", "description": "Amplify GraphQL @predictions tranformer", "repository": { "type": "git", @@ -27,12 +27,12 @@ "test": "jest" }, "dependencies": { - "@aws-amplify/graphql-transformer-core": "0.6.3", - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-transformer-core": "0.7.0", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/aws-appsync": "~1.72.0", - "@aws-cdk/core": "~1.72.0", "@aws-cdk/aws-iam": "~1.72.0", "@aws-cdk/aws-lambda": "~1.72.0", + "@aws-cdk/core": "~1.72.0", "graphql": "^14.5.8", "graphql-mapping-template": "4.18.1", "graphql-transformer-common": "4.19.4" diff --git a/packages/amplify-graphql-searchable-transformer/CHANGELOG.md b/packages/amplify-graphql-searchable-transformer/CHANGELOG.md index bfac2df81c7..1ce7b7d09ca 100644 --- a/packages/amplify-graphql-searchable-transformer/CHANGELOG.md +++ b/packages/amplify-graphql-searchable-transformer/CHANGELOG.md @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-searchable-transformer@0.2.3...@aws-amplify/graphql-searchable-transformer@0.3.0) (2021-07-12) + + +### Bug Fixes + +* get mock working with gql transformer v2 ([#7574](https://github.com/aws-amplify/amplify-cli/issues/7574)) ([4fa2900](https://github.com/aws-amplify/amplify-cli/commit/4fa2900d6b9ca515677d06bdffe29f56401b9c86)) + + +### Features + +* category graphql/searchable sort multiple fields ([#7553](https://github.com/aws-amplify/amplify-cli/issues/7553)) ([03973ee](https://github.com/aws-amplify/amplify-cli/commit/03973eedbb5e4d755609b56b7bebf937783d5a67)) +* **cli:** upgrade elastic search version to 7.x ([#7556](https://github.com/aws-amplify/amplify-cli/issues/7556)) ([3b46e2a](https://github.com/aws-amplify/amplify-cli/commit/3b46e2a1313b3092109a2c356b9a73e23439f4f2)) +* port [@predictions](https://github.com/predictions) to GraphQL Transformer v2 ([#7387](https://github.com/aws-amplify/amplify-cli/issues/7387)) ([3f2e647](https://github.com/aws-amplify/amplify-cli/commit/3f2e647b9dfe14aa5919b46f53342937dd0c7fa9)) + + + + + ## [0.2.3](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-searchable-transformer@0.2.2...@aws-amplify/graphql-searchable-transformer@0.2.3) (2021-06-30) **Note:** Version bump only for package @aws-amplify/graphql-searchable-transformer diff --git a/packages/amplify-graphql-searchable-transformer/package.json b/packages/amplify-graphql-searchable-transformer/package.json index d5ebde45640..5dd85d43f4c 100644 --- a/packages/amplify-graphql-searchable-transformer/package.json +++ b/packages/amplify-graphql-searchable-transformer/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-searchable-transformer", - "version": "0.2.3", + "version": "0.3.0", "description": "Amplfy GraphQL @searchable transformer", "repository": { "type": "git", @@ -27,8 +27,8 @@ "test": "jest" }, "dependencies": { - "@aws-amplify/graphql-transformer-core": "0.6.3", - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-transformer-core": "0.7.0", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/aws-appsync": "~1.72.0", "@aws-cdk/aws-dynamodb": "~1.72.0", "@aws-cdk/aws-ec2": "~1.72.0", diff --git a/packages/amplify-graphql-transformer-core/CHANGELOG.md b/packages/amplify-graphql-transformer-core/CHANGELOG.md index b9232204b47..4547601d104 100644 --- a/packages/amplify-graphql-transformer-core/CHANGELOG.md +++ b/packages/amplify-graphql-transformer-core/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.7.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-transformer-core@0.6.3...@aws-amplify/graphql-transformer-core@0.7.0) (2021-07-12) + + +### Features + +* port [@predictions](https://github.com/predictions) to GraphQL Transformer v2 ([#7387](https://github.com/aws-amplify/amplify-cli/issues/7387)) ([3f2e647](https://github.com/aws-amplify/amplify-cli/commit/3f2e647b9dfe14aa5919b46f53342937dd0c7fa9)) + + + + + ## [0.6.3](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-transformer-core@0.6.2...@aws-amplify/graphql-transformer-core@0.6.3) (2021-06-30) diff --git a/packages/amplify-graphql-transformer-core/package.json b/packages/amplify-graphql-transformer-core/package.json index 28c986ad1b8..3553a64a257 100644 --- a/packages/amplify-graphql-transformer-core/package.json +++ b/packages/amplify-graphql-transformer-core/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-transformer-core", - "version": "0.6.3", + "version": "0.7.0", "description": "A framework to transform from GraphQL SDL to AWS CloudFormation.", "repository": { "type": "git", @@ -26,7 +26,7 @@ "clean": "rimraf ./lib" }, "dependencies": { - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/assets": "~1.72.0", "@aws-cdk/aws-applicationautoscaling": "~1.72.0", "@aws-cdk/aws-appsync": "~1.72.0", diff --git a/packages/amplify-graphql-transformer-interfaces/CHANGELOG.md b/packages/amplify-graphql-transformer-interfaces/CHANGELOG.md index 4a792e79015..1b5e09fa4d1 100644 --- a/packages/amplify-graphql-transformer-interfaces/CHANGELOG.md +++ b/packages/amplify-graphql-transformer-interfaces/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.7.0](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-transformer-interfaces@1.6.1...@aws-amplify/graphql-transformer-interfaces@1.7.0) (2021-07-12) + + +### Features + +* port [@predictions](https://github.com/predictions) to GraphQL Transformer v2 ([#7387](https://github.com/aws-amplify/amplify-cli/issues/7387)) ([3f2e647](https://github.com/aws-amplify/amplify-cli/commit/3f2e647b9dfe14aa5919b46f53342937dd0c7fa9)) + + + + + ## [1.6.1](https://github.com/aws-amplify/amplify-cli/compare/@aws-amplify/graphql-transformer-interfaces@1.6.0...@aws-amplify/graphql-transformer-interfaces@1.6.1) (2021-06-24) diff --git a/packages/amplify-graphql-transformer-interfaces/package.json b/packages/amplify-graphql-transformer-interfaces/package.json index 8f60bc17dad..69cb6cb383c 100644 --- a/packages/amplify-graphql-transformer-interfaces/package.json +++ b/packages/amplify-graphql-transformer-interfaces/package.json @@ -1,6 +1,6 @@ { "name": "@aws-amplify/graphql-transformer-interfaces", - "version": "1.6.1", + "version": "1.7.0", "description": "Amplify GraphQL transformer interface definitions", "repository": { "type": "git", diff --git a/packages/amplify-headless-interface/CHANGELOG.md b/packages/amplify-headless-interface/CHANGELOG.md index 2429f565589..1666ec14e77 100644 --- a/packages/amplify-headless-interface/CHANGELOG.md +++ b/packages/amplify-headless-interface/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [1.8.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-headless-interface@1.7.0...amplify-headless-interface@1.8.0) (2021-07-12) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-cli/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-cli/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + # [1.7.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-headless-interface@1.6.1...amplify-headless-interface@1.7.0) (2021-06-24) diff --git a/packages/amplify-headless-interface/package.json b/packages/amplify-headless-interface/package.json index efba98cf684..6c201f0b239 100644 --- a/packages/amplify-headless-interface/package.json +++ b/packages/amplify-headless-interface/package.json @@ -1,6 +1,6 @@ { "name": "amplify-headless-interface", - "version": "1.7.0", + "version": "1.8.0", "description": "interfaces for amplify headless mode payloads", "main": "lib/index.js", "scripts": { diff --git a/packages/amplify-migration-tests/CHANGELOG.md b/packages/amplify-migration-tests/CHANGELOG.md index 07ca9bf8975..50adf996459 100644 --- a/packages/amplify-migration-tests/CHANGELOG.md +++ b/packages/amplify-migration-tests/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [3.1.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-migration-tests@3.0.2...amplify-migration-tests@3.1.0) (2021-07-12) + + +### Features + +* support for sign in with apple ([#7413](https://github.com/aws-amplify/amplify-cli/issues/7413)) ([00d6676](https://github.com/aws-amplify/amplify-cli/commit/00d6676b4c1d6995cac01956078f7b6ee6186814)) + + + + + ## [3.0.2](https://github.com/aws-amplify/amplify-cli/compare/amplify-migration-tests@3.0.1...amplify-migration-tests@3.0.2) (2021-06-30) diff --git a/packages/amplify-migration-tests/package.json b/packages/amplify-migration-tests/package.json index 145dfb11a89..4393ad2740e 100644 --- a/packages/amplify-migration-tests/package.json +++ b/packages/amplify-migration-tests/package.json @@ -1,6 +1,6 @@ { "name": "amplify-migration-tests", - "version": "3.0.2", + "version": "3.1.0", "description": "", "repository": { "type": "git", @@ -26,7 +26,7 @@ "setup-profile": "ts-node ./src/configure_tests.ts" }, "dependencies": { - "amplify-e2e-core": "1.22.0", + "amplify-e2e-core": "1.23.0", "aws-sdk": "^2.919.0", "dotenv": "^8.2.0", "esm": "^3.2.25", diff --git a/packages/amplify-provider-awscloudformation/CHANGELOG.md b/packages/amplify-provider-awscloudformation/CHANGELOG.md index 21f3300470a..d2d82f38242 100644 --- a/packages/amplify-provider-awscloudformation/CHANGELOG.md +++ b/packages/amplify-provider-awscloudformation/CHANGELOG.md @@ -3,6 +3,17 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [4.55.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-provider-awscloudformation@4.54.0...amplify-provider-awscloudformation@4.55.0) (2021-07-12) + + +### Features + +* port [@predictions](https://github.com/predictions) to GraphQL Transformer v2 ([#7387](https://github.com/aws-amplify/amplify-cli/issues/7387)) ([3f2e647](https://github.com/aws-amplify/amplify-cli/commit/3f2e647b9dfe14aa5919b46f53342937dd0c7fa9)) + + + + + # [4.54.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-provider-awscloudformation@4.53.0...amplify-provider-awscloudformation@4.54.0) (2021-06-30) diff --git a/packages/amplify-provider-awscloudformation/package.json b/packages/amplify-provider-awscloudformation/package.json index 6beddce5874..1555763b7f8 100644 --- a/packages/amplify-provider-awscloudformation/package.json +++ b/packages/amplify-provider-awscloudformation/package.json @@ -1,6 +1,6 @@ { "name": "amplify-provider-awscloudformation", - "version": "4.54.0", + "version": "4.55.0", "description": "AWS CloudFormation Provider", "repository": { "type": "git", @@ -24,13 +24,13 @@ "watch": "tsc --watch" }, "dependencies": { - "@aws-amplify/graphql-function-transformer": "0.3.4", - "@aws-amplify/graphql-http-transformer": "0.4.0", - "@aws-amplify/graphql-model-transformer": "0.4.3", - "@aws-amplify/graphql-predictions-transformer": "0.1.0", - "@aws-amplify/graphql-searchable-transformer": "0.2.3", - "@aws-amplify/graphql-transformer-core": "0.6.3", - "@aws-amplify/graphql-transformer-interfaces": "1.6.1", + "@aws-amplify/graphql-function-transformer": "0.3.5", + "@aws-amplify/graphql-http-transformer": "0.4.1", + "@aws-amplify/graphql-model-transformer": "0.4.4", + "@aws-amplify/graphql-predictions-transformer": "0.2.0", + "@aws-amplify/graphql-searchable-transformer": "0.3.0", + "@aws-amplify/graphql-transformer-core": "0.7.0", + "@aws-amplify/graphql-transformer-interfaces": "1.7.0", "@aws-cdk/assets": "~1.72.0", "@aws-cdk/aws-autoscaling": "~1.72.0", "@aws-cdk/aws-batch": "~1.72.0", diff --git a/packages/amplify-util-headless-input/CHANGELOG.md b/packages/amplify-util-headless-input/CHANGELOG.md index 7216bae034e..781fb62509d 100644 --- a/packages/amplify-util-headless-input/CHANGELOG.md +++ b/packages/amplify-util-headless-input/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.5.1](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-headless-input@1.5.0...amplify-util-headless-input@1.5.1) (2021-07-12) + +**Note:** Version bump only for package amplify-util-headless-input + + + + + # [1.5.0](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-headless-input@1.4.5...amplify-util-headless-input@1.5.0) (2021-06-24) diff --git a/packages/amplify-util-headless-input/package.json b/packages/amplify-util-headless-input/package.json index bf61d8aa704..78c36b264d1 100644 --- a/packages/amplify-util-headless-input/package.json +++ b/packages/amplify-util-headless-input/package.json @@ -1,6 +1,6 @@ { "name": "amplify-util-headless-input", - "version": "1.5.0", + "version": "1.5.1", "description": "Logic for validating objects against JSON-schema specs and performing version upgrades when necessary / possible", "main": "lib/index.js", "scripts": { @@ -16,7 +16,7 @@ "license": "Apache-2.0", "dependencies": { "ajv": "^6.12.2", - "amplify-headless-interface": "1.7.0" + "amplify-headless-interface": "1.8.0" }, "devDependencies": { "@types/json-schema": "^7.0.5" diff --git a/packages/amplify-util-mock/CHANGELOG.md b/packages/amplify-util-mock/CHANGELOG.md index 068f2453f85..dc6befdfaf9 100644 --- a/packages/amplify-util-mock/CHANGELOG.md +++ b/packages/amplify-util-mock/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.33.4](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-mock@3.33.3...amplify-util-mock@3.33.4) (2021-07-12) + +**Note:** Version bump only for package amplify-util-mock + + + + + ## [3.33.3](https://github.com/aws-amplify/amplify-cli/compare/amplify-util-mock@3.33.2...amplify-util-mock@3.33.3) (2021-06-30) **Note:** Version bump only for package amplify-util-mock diff --git a/packages/amplify-util-mock/package.json b/packages/amplify-util-mock/package.json index 1a5c9f837d2..b8ffa95a283 100644 --- a/packages/amplify-util-mock/package.json +++ b/packages/amplify-util-mock/package.json @@ -1,6 +1,6 @@ { "name": "amplify-util-mock", - "version": "3.33.3", + "version": "3.33.4", "description": "amplify cli plugin providing local testing", "repository": { "type": "git", @@ -25,12 +25,12 @@ }, "dependencies": { "@hapi/topo": "^5.0.0", - "amplify-appsync-simulator": "1.27.1", + "amplify-appsync-simulator": "1.27.2", "amplify-category-function": "2.33.0", "amplify-cli-core": "1.24.0", "amplify-codegen": "^2.23.1", "amplify-dynamodb-simulator": "1.19.3", - "amplify-provider-awscloudformation": "4.54.0", + "amplify-provider-awscloudformation": "4.55.0", "amplify-storage-simulator": "1.6.0", "chokidar": "^3.3.1", "detect-port": "^1.3.0", From f9796bd3aca6606f155d37ac6a8931d6bdec25b9 Mon Sep 17 00:00:00 2001 From: "C. Lewis" <1657236+ctjlewis@users.noreply.github.com> Date: Mon, 12 Jul 2021 13:33:32 -0500 Subject: [PATCH 003/125] fix(auth): standardize CloudFormation trigger templates, prevent errors at runtime (#7219) * fix: add-to-group PostConfirmation Lambda should not throw Co-authored-by: Colin Ihrig --- .../boilerplate-create-challenge.js | 4 +- .../captcha-create-challenge.js | 4 +- .../function-template-dir/trigger-index.js | 14 ----- .../function-template-dir/trigger-index.js | 14 ----- .../CustomMessage/verification-link.js | 9 ++-- .../boilerplate-define-challenge.js | 5 +- .../captcha-define-challenge.js | 5 +- .../function-template-dir/trigger-index.js | 14 ----- .../function-template-dir/trigger-index.js | 14 ----- .../triggers/PostConfirmation/add-to-group.js | 29 +++++----- .../function-template-dir/trigger-index.js | 14 ----- .../function-template-dir/trigger-index.js | 14 ----- .../email-filter-allowlist-legacy.js | 8 +-- .../PreSignup/email-filter-allowlist.js | 8 +-- .../PreSignup/email-filter-denylist-legacy.js | 8 +-- .../PreSignup/email-filter-denylist.js | 8 +-- .../function-template-dir/trigger-index.js | 14 ----- .../PreTokenGeneration/alter-claims.js | 4 +- .../function-template-dir/trigger-index.js | 14 ----- .../boilerplate-verify.js | 5 +- .../captcha-verify.js | 38 ++++++------- .../function-template-dir/trigger-index.js | 14 ----- .../function-template-dir/trigger-index.js | 39 ++++++++++++++ .../amplify-helpers/trigger-flow.ts | 53 ++++++++++++++++--- 24 files changed, 152 insertions(+), 201 deletions(-) delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/function-template-dir/trigger-index.js delete mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/function-template-dir/trigger-index.js create mode 100644 packages/amplify-category-auth/provider-utils/awscloudformation/triggers/function-template-dir/trigger-index.js diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/boilerplate-create-challenge.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/boilerplate-create-challenge.js index 42145a4faa6..2c48a0f6d41 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/boilerplate-create-challenge.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/boilerplate-create-challenge.js @@ -1,12 +1,12 @@ /* tslint:disable */ /* eslint-disable */ -exports.handler = (event, context) => { +exports.handler = async event => { if (event.request.session.length === 2 && event.request.challengeName === 'CUSTOM_CHALLENGE') { event.response.publicChallengeParameters = { trigger: 'true' }; event.response.privateChallengeParameters = {}; event.response.privateChallengeParameters.answer = process.env.CHALLENGEANSWER; } - context.done(null, event); + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/captcha-create-challenge.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/captcha-create-challenge.js index 65c0ee3a404..98a5231b0bc 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/captcha-create-challenge.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/captcha-create-challenge.js @@ -1,11 +1,11 @@ /* tslint:disable */ /* eslint-disable */ -exports.handler = (event, context) => { +exports.handler = async event => { if (event.request.session.length === 2 && event.request.challengeName === 'CUSTOM_CHALLENGE') { event.response.publicChallengeParameters = { trigger: 'true' }; event.response.privateChallengeParameters = { answer: '' }; event.response.challengeMetadata = 'CAPTCHA_CHALLENGE'; } - context.done(null, event); + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CreateAuthChallenge/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/verification-link.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/verification-link.js index eb81ccc0e72..2a1b41765a8 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/verification-link.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/CustomMessage/verification-link.js @@ -1,4 +1,4 @@ -exports.handler = (event, context, callback) => { +exports.handler = async event => { // Define the URL that you want the user to be directed to after verification is complete if (event.triggerSource === 'CustomMessage_SignUp') { const { codeParameter } = event.request; @@ -26,7 +26,7 @@ exports.handler = (event, context, callback) => { redirectUrl, region, clientId, - }) + }), ).toString('base64'); const bucketUrl = `http://${resourcePrefix}verificationbucket-${process.env.ENV}.s3-website${seperator}${region}.amazonaws.com`; const url = `${bucketUrl}/?data=${payload}&code=${codeParameter}`; @@ -35,8 +35,7 @@ exports.handler = (event, context, callback) => { event.response.emailSubject = process.env.EMAILSUBJECT; event.response.emailMessage = message; console.log('event.response', event.response); - callback(null, event); - } else { - callback(null, event); } + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/boilerplate-define-challenge.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/boilerplate-define-challenge.js index 9acf23986f8..77ed08c72c4 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/boilerplate-define-challenge.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/boilerplate-define-challenge.js @@ -1,4 +1,4 @@ -exports.handler = (event, context) => { +exports.handler = async event => { if (event.request.session.length === 1 && event.request.session[0].challengeName === 'SRP_A') { event.response.issueTokens = false; event.response.failAuthentication = false; @@ -22,5 +22,6 @@ exports.handler = (event, context) => { event.response.issueTokens = false; event.response.failAuthentication = true; } - context.done(null, event); + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/captcha-define-challenge.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/captcha-define-challenge.js index 9acf23986f8..77ed08c72c4 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/captcha-define-challenge.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/captcha-define-challenge.js @@ -1,4 +1,4 @@ -exports.handler = (event, context) => { +exports.handler = async event => { if (event.request.session.length === 1 && event.request.session[0].challengeName === 'SRP_A') { event.response.issueTokens = false; event.response.failAuthentication = false; @@ -22,5 +22,6 @@ exports.handler = (event, context) => { event.response.issueTokens = false; event.response.failAuthentication = true; } - context.done(null, event); + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/DefineAuthChallenge/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostAuthentication/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/add-to-group.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/add-to-group.js index c33dca12fc1..b3cd62cd3a8 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/add-to-group.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/add-to-group.js @@ -1,34 +1,31 @@ /* eslint-disable-line */ const aws = require('aws-sdk'); -exports.handler = async (event, context) => { - const cognitoidentityserviceprovider = new aws.CognitoIdentityServiceProvider({ apiVersion: '2016-04-18' }); +const cognitoidentityserviceprovider = new aws.CognitoIdentityServiceProvider({ + apiVersion: '2016-04-18', +}); + +exports.handler = async event => { const groupParams = { GroupName: process.env.GROUP, UserPoolId: event.userPoolId, }; - const addUserParams = { GroupName: process.env.GROUP, UserPoolId: event.userPoolId, Username: event.userName, }; - + /** + * Check if the group exists; if it doesn't, create it. + */ try { await cognitoidentityserviceprovider.getGroup(groupParams).promise(); } catch (e) { await cognitoidentityserviceprovider.createGroup(groupParams).promise(); } + /** + * Then, add the user to the group. + */ + await cognitoidentityserviceprovider.adminAddUserToGroup(addUserParams).promise(); - try { - await cognitoidentityserviceprovider.adminAddUserToGroup(addUserParams).promise(); - return { - statusCode: 200, - body: JSON.stringify(event) - } - } catch (error) { - return { - statusCode: 500, - body: JSON.stringify(error) - } - } + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PostConfirmation/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreAuthentication/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist-legacy.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist-legacy.js index dc937d2d9c9..1e2873aeffa 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist-legacy.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist-legacy.js @@ -1,4 +1,4 @@ -exports.handler = (event, context, callback) => { +exports.handler = async event => { // allowed domains const ald = process.env.DOMAINWHITELIST.split(',').map(d => d.trim()); @@ -6,8 +6,8 @@ exports.handler = (event, context, callback) => { const domain = email.substring(email.indexOf('@') + 1); if (!ald.includes(domain)) { - callback(new Error(`Invalid email domain: ${domain}`), event); - } else { - callback(null, event); + throw new Error(`Invalid email domain: ${domain}`); } + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist.js index 0f5eb4ad7a8..dc5b9e7b882 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-allowlist.js @@ -1,4 +1,4 @@ -exports.handler = (event, context, callback) => { +exports.handler = async event => { // allowed domains const ald = process.env.DOMAINALLOWLIST.split(',').map(d => d.trim()); @@ -6,8 +6,8 @@ exports.handler = (event, context, callback) => { const domain = email.substring(email.indexOf('@') + 1); if (!ald.includes(domain)) { - callback(new Error(`Invalid email domain: ${domain}`), event); - } else { - callback(null, event); + throw new Error(`Invalid email domain: ${domain}`); } + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist-legacy.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist-legacy.js index ee976c5ebc5..fea04763e6b 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist-legacy.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist-legacy.js @@ -1,4 +1,4 @@ -exports.handler = (event, context, callback) => { +exports.handler = async event => { // disallowed domains const dld = process.env.DOMAINBLACKLIST.split(',').map(d => d.trim()); @@ -6,8 +6,8 @@ exports.handler = (event, context, callback) => { const domain = email.substring(email.indexOf('@') + 1); if (dld.includes(domain)) { - callback(new Error(`Invalid email domain: ${domain}`), event); - } else { - callback(null, event); + throw new Error(`Invalid email domain: ${domain}`); } + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist.js index 034e2e74e3f..49fe4248f84 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/email-filter-denylist.js @@ -1,4 +1,4 @@ -exports.handler = (event, context, callback) => { +exports.handler = async event => { // disallowed domains const dld = process.env.DOMAINDENYLIST.split(',').map(d => d.trim()); @@ -6,8 +6,8 @@ exports.handler = (event, context, callback) => { const domain = email.substring(email.indexOf('@') + 1); if (dld.includes(domain)) { - callback(new Error(`Invalid email domain: ${domain}`), event); - } else { - callback(null, event); + throw new Error(`Invalid email domain: ${domain}`); } + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreSignup/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/alter-claims.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/alter-claims.js index 28427fd51b4..9f9d0f4ce4f 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/alter-claims.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/alter-claims.js @@ -1,4 +1,4 @@ -exports.handler = async (event, context, callback) => { +exports.handler = async event => { event.response = { claimsOverrideDetails: { claimsToAddOrOverride: { @@ -9,5 +9,5 @@ exports.handler = async (event, context, callback) => { }, }; // Return to Amazon Cognito - callback(null, event); + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/PreTokenGeneration/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/boilerplate-verify.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/boilerplate-verify.js index 000a95ad10c..3134d85336f 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/boilerplate-verify.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/boilerplate-verify.js @@ -1,8 +1,9 @@ -exports.handler = (event, context) => { +exports.handler = async event => { if (event.request.privateChallengeParameters.answer === event.request.challengeAnswer) { event.response.answerCorrect = true; } else { event.response.answerCorrect = false; } - context.done(null, event); + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/captcha-verify.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/captcha-verify.js index 06cb4601928..9ad349e0db7 100644 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/captcha-verify.js +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/captcha-verify.js @@ -2,23 +2,23 @@ const axios = require('axios'); /* eslint-enable */ -exports.handler = (event, context, callback) => { - axios - .post( - `https://www.google.com/recaptcha/api/siteverify?secret=${process.env.RECAPTCHASECRET}&response=${event.request.challengeAnswer}`, - {} - ) - .then(response => { - if (response && response.data && response.data.success) { - event.response.answerCorrect = true; - callback(null, event); - } else { - event.response.answerCorrect = false; - callback(new Error('captcha verification error'), event); - } - }) - .catch(() => { - event.response.answerCorrect = false; - callback(new Error('captcha verification error'), event); - }); +exports.handler = async event => { + const response = await axios.post( + `https://www.google.com/recaptcha/api/siteverify?secret=${process.env.RECAPTCHASECRET}&response=${event.request.challengeAnswer}`, + {}, + ); + /** + * Verify that the CAPTCHA challenge succeeded, and if it did, indicate so in + * the event response. + * + * If the challenge fails, throw an error. + */ + const challengeSucceeded = response && response.data && response.data.success; + event.response.answerCorrect = !!challengeSucceeded; + + if (!challengeSucceeded) { + throw new Error('CAPTCHA verification error'); + } + + return event; }; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/function-template-dir/trigger-index.js deleted file mode 100644 index 80c77ea4e38..00000000000 --- a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/VerifyAuthChallengeResponse/function-template-dir/trigger-index.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - this file will loop through all js modules which are uploaded to the lambda resource, - provided that the file names (without extension) are included in the "MODULES" env variable. - "MODULES" is a comma-delimmited string. -*/ -const moduleNames = process.env.MODULES.split(','); -const modules = moduleNames.map(name => require(`./${name}`)); - -exports.handler = (event, context, callback) => { - for (let i = 0; i < modules.length; i += 1) { - const { handler } = modules[i]; - handler(event, context, callback); - } -}; diff --git a/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/function-template-dir/trigger-index.js b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/function-template-dir/trigger-index.js new file mode 100644 index 00000000000..f9854bb863a --- /dev/null +++ b/packages/amplify-category-auth/provider-utils/awscloudformation/triggers/function-template-dir/trigger-index.js @@ -0,0 +1,39 @@ +/** + * @fileoverview + * + * This CloudFormation Trigger creates a handler which awaits the other handlers + * specified in the `MODULES` env var, located at `./${MODULE}`. + */ + +/** + * The names of modules to load are stored as a comma-delimited string in the + * `MODULES` env var. + */ +const moduleNames = process.env.MODULES.split(','); +/** + * The array of imported modules. + */ +const modules = moduleNames.map(name => require(`./${name}`)); + +/** + * This async handler iterates over the given modules and awaits them. + * + * @see https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html#nodejs-handler-async + * + * @param {object} event + * + * The event that triggered this Lambda. + * + * @returns + * + * The handler response. + */ +exports.handler = async event => { + /** + * Instead of naively iterating over all handlers, run them concurrently with + * `await Promise.all(...)`. This would otherwise just be determined by the + * order of names in the `MODULES` var. + */ + await Promise.all(modules.map(module => module.handler(event))); + return event; +}; diff --git a/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts b/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts index cc215b81927..519122431f0 100644 --- a/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts +++ b/packages/amplify-cli/src/extensions/amplify-helpers/trigger-flow.ts @@ -45,6 +45,49 @@ export const addTrigger = async triggerOptions => { triggerEventPath, skipEdit, } = triggerOptions; + /** + * The function template dir for this trigger, i.e. + * PostConfirmation/function-template-dir. + */ + const sourceRoot = path.join(triggerDir, 'function-template-dir'); + /** + * The function template dir for the default trigger template. + */ + const defaultRoot = path.resolve(triggerDir, '..', 'function-template-dir'); + /** + * A key-value map of input filenames and output filepaths. + */ + const templateMap = { + 'trigger-index.js': path.join('src', 'index.js'), + 'package.json.ejs': path.join('src', 'package.json'), + 'event.json': path.join('src', 'event.json'), + }; + /** + * Hold a key-value map of input filepaths and output filenames. + */ + const destMap = {}; + /** + * For each templateFile (i.e. trigger-index.js), use + * {triggerDir}/../{templateFile} if {triggerDir}/{templateFile} + * override does not exist. + */ + const templateFiles = Object.keys(templateMap); + const sourceFiles = templateFiles.map(file => { + const defaultTemplate = path.resolve(defaultRoot, file); + const overrideTemplate = path.resolve(sourceRoot, file); + const templateToUse = fs.existsSync(overrideTemplate) ? overrideTemplate : defaultTemplate; + return path.relative(sourceRoot, templateToUse); + }); + /** + * Map relative template pathnames to their new filenames. + */ + for (const sourceFile of sourceFiles) { + /** + * /path/to/file.js -> file.js + */ + const fileName = path.basename(sourceFile); + destMap[sourceFile] = templateMap[fileName]; + } await context.amplify.invokePluginMethod(context, 'function', undefined, 'add', [ context, @@ -54,13 +97,9 @@ export const addTrigger = async triggerOptions => { trigger: true, cloudResourceTemplatePath: path.join(triggerDir, 'cloudformation-templates', triggerTemplate), functionTemplate: { - sourceRoot: path.join(triggerDir, 'function-template-dir'), - sourceFiles: ['trigger-index.js', 'package.json.ejs', 'event.json'], - destMap: { - 'trigger-index.js': path.join('src', 'index.js'), - 'package.json.ejs': path.join('src', 'package.json'), - 'event.json': path.join('src', 'event.json'), - }, + sourceRoot, + sourceFiles, + destMap, }, modules: values, parentResource, From 34560cd5e386119aef1adaa249cf2b2c13243200 Mon Sep 17 00:00:00 2001 From: Gita Alekhya Paul <54375111+gitaalekhyapaul@users.noreply.github.com> Date: Tue, 13 Jul 2021 00:04:13 +0530 Subject: [PATCH 004/125] fix(amplify-cli): remove redundant prompt #6535 (#7098) * fix: remove redundant prompt #6535 --- .../src/init-steps/s0-analyzeProject.ts | 14 +++++++++++++- packages/amplify-e2e-tests/src/environment/env.ts | 6 ------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/amplify-cli/src/init-steps/s0-analyzeProject.ts b/packages/amplify-cli/src/init-steps/s0-analyzeProject.ts index 95e0ee5a2ef..81e7864dcdf 100644 --- a/packages/amplify-cli/src/init-steps/s0-analyzeProject.ts +++ b/packages/amplify-cli/src/init-steps/s0-analyzeProject.ts @@ -254,8 +254,9 @@ async function getEnvName(context: $TSContext) { await newEnvQuestion(); } else { const allEnvs = context.amplify.getAllEnvs(); + const envAddExec = checkEnvAddExec(context); - if (allEnvs.length > 0) { + if (allEnvs.length > 0 && envAddExec === false) { if (await context.amplify.confirmPrompt('Do you want to use an existing environment?')) { const envQuestion: inquirer.ListQuestion = { type: 'list', @@ -268,6 +269,8 @@ async function getEnvName(context: $TSContext) { } else { await newEnvQuestion(); } + } else if (envAddExec === true && context.parameters.first) { + envName = context.parameters.first; } else { await newEnvQuestion(); } @@ -310,3 +313,12 @@ function getDefaultEditor() { return localEnvInfo.defaultEditor; } + +/** + * Checks if `amplify env add` has been executed + * @param {$TSContext} context The Amplify context object + * @returns `boolean` + */ +function checkEnvAddExec(context): boolean { + return context.parameters.command === 'env' && context.parameters.array[0] === 'add'; +} diff --git a/packages/amplify-e2e-tests/src/environment/env.ts b/packages/amplify-e2e-tests/src/environment/env.ts index ef04cd279b2..bf8f66d891c 100644 --- a/packages/amplify-e2e-tests/src/environment/env.ts +++ b/packages/amplify-e2e-tests/src/environment/env.ts @@ -3,8 +3,6 @@ import { nspawn as spawn, getCLIPath, getSocialProviders, isCI } from 'amplify-e export function addEnvironment(cwd: string, settings: { envName: string; numLayers?: number }): Promise { return new Promise((resolve, reject) => { const chain = spawn(getCLIPath(), ['env', 'add'], { cwd, stripColors: true }) - .wait('Do you want to use an existing environment?') - .sendLine('n') .wait('Enter a name for the environment') .sendLine(settings.envName) .wait('Select the authentication method you want to use:') @@ -58,8 +56,6 @@ export function addEnvironmentYes(cwd: string, settings: { envName: string; disa export function addEnvironmentWithImportedAuth(cwd: string, settings: { envName: string; currentEnvName: string }): Promise { return new Promise((resolve, reject) => { spawn(getCLIPath(), ['env', 'add'], { cwd, stripColors: true }) - .wait('Do you want to use an existing environment?') - .sendConfirmNo() .wait('Enter a name for the environment') .sendLine(settings.envName) .wait('Select the authentication method you want to use:') @@ -179,8 +175,6 @@ export function addEnvironmentHostedUI(cwd: string, settings: { envName: string } = getSocialProviders(); return new Promise((resolve, reject) => { spawn(getCLIPath(), ['env', 'add'], { cwd, stripColors: true }) - .wait('Do you want to use an existing environment?') - .sendLine('n') .wait('Enter a name for the environment') .sendLine(settings.envName) .wait('Select the authentication method you want to use:') From 155a07156cb3467d9e6f6b9cb088bab21ab3bab9 Mon Sep 17 00:00:00 2001 From: John Corser Date: Mon, 12 Jul 2021 14:34:32 -0400 Subject: [PATCH 005/125] fix(amplify-category-notifications): trim whitespace from fcm keys (#7456) this commit prevents a copy/paste issue where an extra newline character comes along with an fcm key. fix #7440 --- .../__tests__/lib/channel-FCM.test.js | 133 ++++++++++++++++++ .../lib/channel-FCM.js | 13 +- 2 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 packages/amplify-category-notifications/__tests__/lib/channel-FCM.test.js diff --git a/packages/amplify-category-notifications/__tests__/lib/channel-FCM.test.js b/packages/amplify-category-notifications/__tests__/lib/channel-FCM.test.js new file mode 100644 index 00000000000..25e8f40bc7c --- /dev/null +++ b/packages/amplify-category-notifications/__tests__/lib/channel-FCM.test.js @@ -0,0 +1,133 @@ +const inquirer = require('inquirer'); +const channelName = 'FCM'; +const channelFCM = require('../../lib/channel-FCM'); + +const mockInquirer = answers => { + inquirer.prompt = async prompts => { + [].concat(prompts).forEach(function (prompt) { + if (!(prompt.name in answers) && typeof prompt.default !== 'undefined') { + answers[prompt.name] = prompt.default; + } + }); + + return answers; + }; +}; + +describe('channel-FCM', () => { + const mockServiceOutput = {}; + const mockChannelOutput = { Enabled: true }; + mockServiceOutput[channelName] = mockChannelOutput; + + const mockPinpointResponseErr = new Error('channel-FCM.test.js error'); + const mockPinpointResponseData = { + FCMChannelResponse: {}, + }; + + const mockPinpointClient = { + updateGcmChannel: jest.fn((_, cb) => { + return new Promise(() => { + cb(null, mockPinpointResponseData); + }); + }), + }; + + const mockPinpointClientReject = { + updateGcmChannel: jest.fn((_, cb) => { + return new Promise(() => { + cb(mockPinpointResponseErr); + }); + }), + }; + + let mockContext = { + exeInfo: { + serviceMeta: { + output: mockServiceOutput, + }, + pinpointClient: mockPinpointClient, + }, + print: { + info: jest.fn(), + error: jest.fn(), + }, + }; + + let mockContextReject = { + exeInfo: { + serviceMeta: { + output: mockServiceOutput, + }, + pinpointClient: mockPinpointClientReject, + }, + print: { + info: jest.fn(), + error: jest.fn(), + }, + }; + + test('configure', async () => { + mockChannelOutput.Enabled = true; + mockInquirer({ disableChannel: true }); + + await channelFCM.configure(mockContext).then(() => { + expect(mockPinpointClient.updateGcmChannel).toBeCalled(); + }); + + mockChannelOutput.Enabled = true; + mockInquirer({ disableChannel: false }); + await channelFCM.configure(mockContext).then(() => { + expect(mockPinpointClient.updateGcmChannel).toBeCalled(); + }); + + mockChannelOutput.Enabled = false; + mockInquirer({ enableChannel: true }); + await channelFCM.configure(mockContext).then(() => { + expect(mockPinpointClient.updateGcmChannel).toBeCalled(); + }); + }); + + test('enable', async () => { + mockInquirer({ ApiKey: 'ApiKey-abc123' }); + await channelFCM.enable(mockContext, 'successMessage').then(data => { + expect(mockPinpointClient.updateGcmChannel).toBeCalled(); + expect(data).toEqual(mockPinpointResponseData); + }); + }); + + test('enable with newline', async () => { + mockInquirer({ ApiKey: 'ApiKey-abc123\n' }); + await channelFCM.enable(mockContext, 'successMessage').then(data => { + expect(mockPinpointClient.updateGcmChannel).toBeCalledWith( + { + ApplicationId: undefined, + GCMChannelRequest: { + ApiKey: 'ApiKey-abc123', + Enabled: true, + }, + }, + expect.anything(), + ); + expect(data).toEqual(mockPinpointResponseData); + }); + }); + + test('enable unsuccessful', async () => { + mockInquirer({ ApiKey: 'ApiKey-abc123' }); + await channelFCM.enable(mockContextReject, 'successMessage').catch(err => { + expect(mockPinpointClient.updateGcmChannel).toBeCalled(); + expect(err).toEqual(mockPinpointResponseErr); + }); + }); + + test('disable', async () => { + await channelFCM.disable(mockContext).then(data => { + expect(mockPinpointClient.updateGcmChannel).toBeCalled(); + expect(data).toEqual(mockPinpointResponseData); + }); + }); + + test('disable unsuccessful', async () => { + await expect(channelFCM.disable(mockContextReject)).rejects.toThrow(mockPinpointResponseErr); + }); +}); diff --git a/packages/amplify-category-notifications/lib/channel-FCM.js b/packages/amplify-category-notifications/lib/channel-FCM.js index bbc283bb157..8852636899d 100644 --- a/packages/amplify-category-notifications/lib/channel-FCM.js +++ b/packages/amplify-category-notifications/lib/channel-FCM.js @@ -51,7 +51,7 @@ async function enable(context, successMessage) { default: channelOutput.ApiKey, }, ]; - answers = await inquirer.prompt(questions); + answers = trimAnswers(await inquirer.prompt(questions)); } const params = { @@ -104,7 +104,7 @@ async function disable(context) { default: channelOutput.ApiKey, }, ]; - answers = await inquirer.prompt(questions); + answers = trimAnswers(await inquirer.prompt(questions)); } const params = { @@ -154,6 +154,15 @@ function pull(context, pinpointApp) { }); } +function trimAnswers(answers) { + for (const [key, value] of Object.entries(answers)) { + if (typeof answers[key] === 'string') { + answers[key] = value.trim(); + } + } + return answers; +} + module.exports = { configure, enable, From 8dfb71cb78fafc108a3d9d67505d46c208607026 Mon Sep 17 00:00:00 2001 From: "Rafael M. Koike" Date: Mon, 12 Jul 2021 14:35:47 -0400 Subject: [PATCH 006/125] fix(amplify-provider-awscloudformation): rebase code and fixed yaml template load (#7518) rebase code from latest updates and fixed yaml template load --- .../src/push-resources.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/amplify-provider-awscloudformation/src/push-resources.ts b/packages/amplify-provider-awscloudformation/src/push-resources.ts index f367bf67697..b5a948a8d0c 100644 --- a/packages/amplify-provider-awscloudformation/src/push-resources.ts +++ b/packages/amplify-provider-awscloudformation/src/push-resources.ts @@ -16,6 +16,7 @@ import { $TSMeta, DeploymentStepState, DeploymentStepStatus, + readCFNTemplate, } from 'amplify-cli-core'; import ora from 'ora'; import { S3 } from './aws-utils/aws-s3'; @@ -619,25 +620,25 @@ async function prepareResource(context: $TSContext, resource: $TSAny) { const cfnParamsFilePath = path.normalize(path.join(resourceDir, 'parameters.json')); JSONUtilities.writeJson(cfnParamsFilePath, cfnParams); } else { - const cfnMeta = JSONUtilities.readJson<$TSAny>(cfnFilePath); - cfnMeta.Parameters.deploymentBucketName = paramType; - cfnMeta.Parameters.s3Key = paramType; + const { cfnTemplate } = await readCFNTemplate(cfnFilePath); + cfnTemplate.Parameters.deploymentBucketName = paramType; + cfnTemplate.Parameters.s3Key = paramType; const deploymentBucketNameRef = 'deploymentBucketName'; const s3KeyRef = 's3Key'; - if (cfnMeta.Resources.LambdaFunction.Type === 'AWS::Serverless::Function') { - cfnMeta.Resources.LambdaFunction.Properties.CodeUri = { + if (cfnTemplate.Resources.LambdaFunction.Type === 'AWS::Serverless::Function') { + cfnTemplate.Resources.LambdaFunction.Properties.CodeUri = { Bucket: Fn.Ref(deploymentBucketNameRef), Key: Fn.Ref(s3KeyRef), }; } else { - cfnMeta.Resources.LambdaFunction.Properties.Code = { + cfnTemplate.Resources.LambdaFunction.Properties.Code = { S3Bucket: Fn.Ref(deploymentBucketNameRef), S3Key: Fn.Ref(s3KeyRef), }; } storeS3BucketInfo(category, s3Bucket, envName, resourceName, s3Key); - JSONUtilities.writeJson(cfnFilePath, cfnMeta); + JSONUtilities.writeJson(cfnFilePath, cfnTemplate); } } From b1b6291ac79b18b55723f9463aa93005ab75be88 Mon Sep 17 00:00:00 2001 From: akshbhu <39866697+akshbhu@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:36:11 -0700 Subject: [PATCH 007/125] fix: check for undefined permissions when removing dependent permissions (#7594) * fix: check for undefined permissions when removing dependent permissions --- .../utils/getDependentFunction.test.ts | 14 ++++---------- .../utils/getDependentFunction.ts | 10 ++++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/getDependentFunction.test.ts b/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/getDependentFunction.test.ts index e93276afab1..df721f64d4c 100644 --- a/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/getDependentFunction.test.ts +++ b/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/getDependentFunction.test.ts @@ -68,7 +68,7 @@ const loadResourceParameters_mock = loadFunctionParameters as jest.MockedFunctio test('get dependent functions', async () => { jest.clearAllMocks(); - const modelsDeleted = ['model3']; + const modelsDeleted = ['model3', 'model2']; const FunctionMetaExpected = ['fn2', 'fn3']; loadResourceParameters_mock .mockReturnValueOnce({ @@ -91,9 +91,9 @@ test('get dependent functions', async () => { expect(fnMetaToBeUpdated.map(resource => resource.resourceName).toString()).toBe(FunctionMetaExpected.toString()); }); -test('get dependent functions', async () => { +test('get dependent functions with empty permissions', async () => { jest.clearAllMocks(); - const modelsDeleted = ['model1', 'model2']; + const modelsDeleted = ['model3']; const FunctionMetaExpected = ['fn2']; loadResourceParameters_mock .mockReturnValueOnce({ @@ -105,13 +105,7 @@ test('get dependent functions', async () => { }, }, }) - .mockReturnValueOnce({ - permissions: { - storage: { - model3: ['create'], - }, - }, - }); + .mockReturnValueOnce({}); const fnMetaToBeUpdated = await lambdasWithApiDependency((contextStub as unknown) as $TSContext, allResources, backendDir, modelsDeleted); expect(fnMetaToBeUpdated.map(resource => resource.resourceName).toString()).toBe(FunctionMetaExpected.toString()); }); diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/getDependentFunction.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/getDependentFunction.ts index 8b254f7a03f..8c8963b8b1a 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/getDependentFunction.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/getDependentFunction.ts @@ -27,10 +27,12 @@ export async function lambdasWithApiDependency( const selectedCategories = currentParameters.permissions; let deletedModelFound: boolean; - for (const selectedResources of Object.values(selectedCategories)) { - deletedModelFound = Object.keys(selectedResources).some(r => modelsDeleted.includes(r)); - if (deletedModelFound) { - dependentFunctions.push(lambda); + if (typeof selectedCategories === 'object' && selectedCategories !== null) { + for (const selectedResources of Object.values(selectedCategories)) { + deletedModelFound = Object.keys(selectedResources).some(r => modelsDeleted.includes(r)); + if (deletedModelFound) { + dependentFunctions.push(lambda); + } } } } From 0027abb1a8cc18c4ec0bac1ddf0191e37322bbff Mon Sep 17 00:00:00 2001 From: Mohammed Ali Chherawalla Date: Tue, 13 Jul 2021 00:06:46 +0530 Subject: [PATCH 008/125] =?UTF-8?q?fix(amplify-appsync-simulator):=20strin?= =?UTF-8?q?g=20functions=20not=20called=20on=20items=20=E2=80=A6=20(#7636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(amplify-appsync-simulator): string functions not called on items of JavaArray in the resolvers * feat(amplify-appsync-simulator): added toJavaString that accepts a string and returns a JavaString * feat(amplify-appsync-simulator): map.keySet returns an a JavaArray with elements of type JavaString * feat(amplify-appsync-simulator): using this.mapper in map.keySet --- .../src/__tests__/velocity/value-mapper/map.test.ts | 9 +++++++++ .../src/velocity/value-mapper/map.ts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts b/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts index 2cfbbcb56e9..60e5fee115f 100644 --- a/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts +++ b/packages/amplify-appsync-simulator/src/__tests__/velocity/value-mapper/map.test.ts @@ -1,4 +1,7 @@ +import { JavaArray } from './../../../velocity/value-mapper/array'; import { JavaMap } from '../../../velocity/value-mapper/map'; +import { JavaString } from '../../../velocity/value-mapper/string'; +import { map as mapper } from '../../../velocity/value-mapper/mapper'; describe('JavaMap', () => { let identityMapper = jest.fn().mockImplementation(val => val); @@ -66,6 +69,12 @@ describe('JavaMap', () => { expect(map.keySet().toJSON()).toEqual(['foo', 'bar']); }); + it('keySet returns a JavaArray with each element of type JavaString', () => { + const obj = { foo: 'Foo Value', bar: 'Bar Value' }; + const map = new JavaMap(obj, mapper); + expect(map.keySet()).toEqual(new JavaArray([new JavaString('foo'), new JavaString('bar')], mapper)); + }); + it('put', () => { const map = new JavaMap({}, identityMapper); map.put('foo', 'Foo Value'); diff --git a/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts b/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts index d075fa022b0..184f91f0d36 100644 --- a/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts +++ b/packages/amplify-appsync-simulator/src/velocity/value-mapper/map.ts @@ -56,7 +56,7 @@ export class JavaMap { } keySet() { - return new JavaArray(Array.from(this.map.keys()), this.mapper); + return new JavaArray(Array.from(this.map.keys()).map(this.mapper as any), this.mapper); } put(key, value) { From 0e9005e2bc5d08a0065a14165804f32d70624e41 Mon Sep 17 00:00:00 2001 From: Bentheburrito <33915719+Bentheburrito@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:38:12 -0700 Subject: [PATCH 009/125] docs(cli): add 'future' to post-'amplify pull' success message for clarity (#7647) change `Run 'amplify pull' to sync upstream changes.` -> `Run 'amplify pull' to sync future upstream changes.` as desired in #5202 re #5202 Co-authored-by: Stuti Prasad <43947328+studpeps@users.noreply.github.com> --- packages/amplify-cli/src/attach-backend.ts | 4 ++-- packages/amplify-e2e-core/src/init/amplifyPull.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/amplify-cli/src/attach-backend.ts b/packages/amplify-cli/src/attach-backend.ts index 5202929e775..81af52445d5 100644 --- a/packages/amplify-cli/src/attach-backend.ts +++ b/packages/amplify-cli/src/attach-backend.ts @@ -70,14 +70,14 @@ async function onSuccess(context: $TSContext) { context.print.info(''); context.print.success(`Successfully pulled backend environment ${envName} from the cloud.`); - context.print.info(`Run 'amplify pull' to sync upstream changes.`); + context.print.info(`Run 'amplify pull' to sync future upstream changes.`); context.print.info(''); } else { removeFolderStructure(); context.print.info(''); context.print.success(`Added backend environment config object to your project.`); - context.print.info(`Run 'amplify pull' to sync upstream changes.`); + context.print.info(`Run 'amplify pull' to sync future upstream changes.`); context.print.info(''); } } else { diff --git a/packages/amplify-e2e-core/src/init/amplifyPull.ts b/packages/amplify-e2e-core/src/init/amplifyPull.ts index df3fc7dacab..3193465878e 100644 --- a/packages/amplify-e2e-core/src/init/amplifyPull.ts +++ b/packages/amplify-e2e-core/src/init/amplifyPull.ts @@ -55,7 +55,7 @@ export function amplifyPull( } if (settings.emptyDir) { - chain.wait(/Successfully pulled backend environment .+ from the cloud\./).wait("Run 'amplify pull' to sync upstream changes."); + chain.wait(/Successfully pulled backend environment .+ from the cloud\./).wait("Run 'amplify pull' to sync future upstream changes."); } else { chain.wait('Post-pull status').wait('Current Environment').wait(tableHeaderRegex).wait(tableSeperator); } From 5115c129f3bfc39c9cfea3338d4344b9872e94fd Mon Sep 17 00:00:00 2001 From: Marc VandenBerg Date: Mon, 12 Jul 2021 14:39:10 -0400 Subject: [PATCH 010/125] Create: BatchSize and MaximumBatchingWindow parameters, V2 streaming lambda (#7651) * fix: Move credential validation to the top function call getProfileCredentials isn't always pulling from a file with an access key/secret key, so validation can error out in the case of source profiles. Moving this to the top function getProfiledAwsConfig and performing the validation on the AWS config instead means we can accommodate source profiles. * Change: Make batch size parameterized on streaming * Change: batch size and batching window duration are parameters * Change: Decrease searchable streaming MaximumBatchingWindow to 1 second Co-authored-by: Vandenberg --- .../src/cdk/create-cfnParameters.ts | 20 +++++++++++++++++++ .../src/cdk/create-streaming-lambda.ts | 7 +++++-- .../src/graphql-searchable-transformer.ts | 2 +- .../src/ResourceConstants.ts | 2 ++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/amplify-graphql-searchable-transformer/src/cdk/create-cfnParameters.ts b/packages/amplify-graphql-searchable-transformer/src/cdk/create-cfnParameters.ts index b54a2d26b53..9d9191ee12c 100644 --- a/packages/amplify-graphql-searchable-transformer/src/cdk/create-cfnParameters.ts +++ b/packages/amplify-graphql-searchable-transformer/src/cdk/create-cfnParameters.ts @@ -7,6 +7,8 @@ export function createParametersStack(stack: Stack): Map { ElasticsearchStreamingLambdaHandlerName, ElasticsearchStreamingLambdaRuntime, ElasticsearchStreamingFunctionName, + ElasticsearchStreamBatchSize, + ElasticsearchStreamMaximumBatchingWindowInSeconds, ElasticsearchStreamingIAMRoleName, ElasticsearchDebugStreamingLambda, ElasticsearchInstanceCount, @@ -47,6 +49,24 @@ export function createParametersStack(stack: Stack): Map { }), ], + [ + ElasticsearchStreamBatchSize, + new CfnParameter(stack, ElasticsearchStreamBatchSize, { + description: 'The maximum number of records to stream to Elasticsearch per batch.', + type: 'Number', + default: 100 + }) + ], + + [ + ElasticsearchStreamMaximumBatchingWindowInSeconds, + new CfnParameter(stack, ElasticsearchStreamMaximumBatchingWindowInSeconds, { + description: "The maximum amount of time in seconds to wait for DynamoDB stream records before sending to streaming lambda.", + type: 'Number', + default: 1 + }) + ], + [ ElasticsearchAccessIAMRoleName, new CfnParameter(stack, ElasticsearchStreamingIAMRoleName, { diff --git a/packages/amplify-graphql-searchable-transformer/src/cdk/create-streaming-lambda.ts b/packages/amplify-graphql-searchable-transformer/src/cdk/create-streaming-lambda.ts index a3d18ad7c7b..f19a5752a09 100644 --- a/packages/amplify-graphql-searchable-transformer/src/cdk/create-streaming-lambda.ts +++ b/packages/amplify-graphql-searchable-transformer/src/cdk/create-streaming-lambda.ts @@ -1,6 +1,6 @@ import { GraphQLAPIProvider } from '@aws-amplify/graphql-transformer-interfaces'; import { EventSourceMapping, IFunction, LayerVersion, Runtime, StartingPosition } from '@aws-cdk/aws-lambda'; -import { CfnParameter, Construct, Fn, Stack } from '@aws-cdk/core'; +import { CfnParameter, Construct, Fn, Stack, Duration } from '@aws-cdk/core'; import { Effect, IRole, Policy, PolicyStatement, Role, ServicePrincipal } from '@aws-cdk/aws-iam'; import { ResourceConstants, SearchableResourceIDs } from 'graphql-transformer-common'; import * as path from 'path'; @@ -71,13 +71,16 @@ export const createEventSourceMapping = ( stack: Construct, type: string, target: IFunction, + parameterMap: Map, tableStreamArn?: string, ): EventSourceMapping => { + const { ElasticsearchStreamBatchSize, ElasticsearchStreamMaximumBatchingWindowInSeconds } = ResourceConstants.PARAMETERS; assert(tableStreamArn); return new EventSourceMapping(stack, SearchableResourceIDs.SearchableEventSourceMappingID(type), { eventSourceArn: tableStreamArn, target, - batchSize: 1, + batchSize: parameterMap.get(ElasticsearchStreamBatchSize)!.valueAsNumber, + maxBatchingWindow: Duration.seconds(parameterMap.get(ElasticsearchStreamMaximumBatchingWindowInSeconds)!.valueAsNumber), enabled: true, startingPosition: StartingPosition.LATEST, }); diff --git a/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts b/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts index 3ab9a97c453..24f445dc8dd 100644 --- a/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts +++ b/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts @@ -119,7 +119,7 @@ export class SearchableModelTransformer extends TransformerPluginBase { ddbTable.grantStreamRead(lambdaRole); // creates event source mapping from ddb to lambda - createEventSourceMapping(stack, type, lambda, ddbTable.tableStreamArn); + createEventSourceMapping(stack, type, lambda, parameterMap, ddbTable.tableStreamArn); const { attributeName } = (table as any).keySchema.find((att: any) => att.keyType === 'HASH'); assert(typeName); diff --git a/packages/graphql-transformer-common/src/ResourceConstants.ts b/packages/graphql-transformer-common/src/ResourceConstants.ts index 088a638b91a..828fa89e36e 100644 --- a/packages/graphql-transformer-common/src/ResourceConstants.ts +++ b/packages/graphql-transformer-common/src/ResourceConstants.ts @@ -54,6 +54,8 @@ export class ResourceConstants { ElasticsearchDebugStreamingLambda: 'ElasticSearchDebugStreamingLambda', ElasticsearchStreamingIAMRoleName: 'ElasticSearchStreamingIAMRoleName', ElasticsearchStreamingFunctionName: 'ElasticSearchStreamingFunctionName', + ElasticsearchStreamBatchSize: 'ElasticSearchStreamBatchSize', + ElasticsearchStreamMaximumBatchingWindowInSeconds: 'ElasticSearchStreamMaximumBatchingWindowInSeconds', ElasticsearchInstanceCount: 'ElasticSearchInstanceCount', ElasticsearchInstanceType: 'ElasticSearchInstanceType', ElasticsearchEBSVolumeGB: 'ElasticSearchEBSVolumeGB', From 38955e3c065538cec99059feb8641b9e644bd8aa Mon Sep 17 00:00:00 2001 From: Yathi <511386+yuth@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:40:02 -0700 Subject: [PATCH 011/125] fix: show friendly error message when pull fails with EPERM (#7653) * fix: show friendly error message when pull fails with EPERM fix #7448 Co-authored-by: Colin Ihrig --- packages/amplify-cli/src/attach-backend.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/amplify-cli/src/attach-backend.ts b/packages/amplify-cli/src/attach-backend.ts index 81af52445d5..68b74535c29 100644 --- a/packages/amplify-cli/src/attach-backend.ts +++ b/packages/amplify-cli/src/attach-backend.ts @@ -104,8 +104,16 @@ function backupAmplifyFolder() { throw error; } - - fs.moveSync(amplifyDirPath, backupAmplifyDirPath); + try { + fs.moveSync(amplifyDirPath, backupAmplifyDirPath); + } catch (e) { + if (e.code === 'EPERM') { + throw new Error( + 'Could not attach the backend to the project. Ensure that there are no applications locking the `amplify` folder and try again', + ); + } + throw e; + } } } From 3c0823e8e004e00808351e958f5b587e8d77bd01 Mon Sep 17 00:00:00 2001 From: Stuti Prasad <43947328+studpeps@users.noreply.github.com> Date: Tue, 13 Jul 2021 00:10:43 +0530 Subject: [PATCH 012/125] fix(amplify-category-auth): \n made OS specific (#7663) * style:removed extra whitespaces and standardized tabs in auth-templates * fix(amplify-category-auth): fixed newline escape sequence to be os specific fix #7662 --- .../awscloudformation/utils/message-printer.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/message-printer.test.ts b/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/message-printer.test.ts index 84a01121ca1..d6bbaee837c 100644 --- a/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/message-printer.test.ts +++ b/packages/amplify-category-auth/src/__tests__/provider-utils/awscloudformation/utils/message-printer.test.ts @@ -1,5 +1,6 @@ import { printSMSSandboxWarning } from '../../../../provider-utils/awscloudformation/utils/message-printer'; import { BannerMessage } from 'amplify-cli-core'; +import os from 'os'; jest.mock('amplify-cli-core'); const printMock = { warning: jest.fn(), @@ -16,7 +17,7 @@ describe('printSMSSandboxWarning', () => { const message = 'BannerMessage'; mockedGetMessage.mockResolvedValueOnce(message); await printSMSSandboxWarning(printMock); - expect(printMock.warning).toHaveBeenCalledWith(`${message}\n`); + expect(printMock.warning).toHaveBeenCalledWith(`${message}${os.EOL}`); expect(mockedGetMessage).toHaveBeenCalledWith('COGNITO_SMS_SANDBOX_CATEGORY_AUTH_ADD_OR_UPDATE_INFO'); }); From 968868103744edcfbed6b082b3d9a92867180f73 Mon Sep 17 00:00:00 2001 From: John Hockett Date: Mon, 12 Jul 2021 11:40:58 -0700 Subject: [PATCH 013/125] fix: add/update function when some LL are not yet migrated (#7674) * fix: add/update function when some LL are not yet migrated --- .../utils/addLayerToFunctionUtil.test.ts | 1 + .../utils/addLayerToFunctionUtils.ts | 21 +++++-- .../utils/layerConfiguration.ts | 14 ++++- .../utils/layerMigrationUtils.ts | 63 ++++++++++++------- .../awscloudformation/utils/storeResources.ts | 2 +- .../src/categories/lambda-function.ts | 6 +- .../src/categories/lambda-layer.ts | 2 +- .../layer-migration.test.ts | 25 ++++++-- .../migration-helpers/legacy-lambda-layer.ts | 1 - 9 files changed, 94 insertions(+), 41 deletions(-) diff --git a/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/addLayerToFunctionUtil.test.ts b/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/addLayerToFunctionUtil.test.ts index c5b7a4697e9..d3a1955fd09 100644 --- a/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/addLayerToFunctionUtil.test.ts +++ b/packages/amplify-category-function/src/__tests__/provider-utils/awscloudformation/utils/addLayerToFunctionUtil.test.ts @@ -21,6 +21,7 @@ jest.mock('../../../../provider-utils/awscloudformation/utils/layerCloudState'); jest.mock('../../../../provider-utils/awscloudformation/utils/layerConfiguration', () => ({ getLayerRuntimes: jest.fn(), })); +jest.mock('../../../../provider-utils/awscloudformation/utils/layerMigrationUtils'); const getLayerRuntimes_mock = getLayerRuntimes as jest.MockedFunction; const inquirer_mock = inquirer as jest.Mocked; diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/addLayerToFunctionUtils.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/addLayerToFunctionUtils.ts index 4cca83a9113..f9642dd701f 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/addLayerToFunctionUtils.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/addLayerToFunctionUtils.ts @@ -8,6 +8,7 @@ import { ServiceName } from './constants'; import { LayerCloudState } from './layerCloudState'; import { getLayerRuntimes } from './layerConfiguration'; import { layerVersionQuestion, mapVersionNumberToChoice } from './layerHelpers'; +import { getLegacyLayerState, LegacyState } from './layerMigrationUtils'; export const provideExistingARNsPrompt = 'Provide existing Lambda layer ARNs'; const layerSelectionPrompt = 'Provide existing layers or select layers in this project to access from this function (pick up to 5):'; @@ -38,8 +39,10 @@ export const askLayerSelection = async ( const layerOptions = _.keys(functionMeta) .filter(key => functionMeta[key].service === ServiceName.LambdaLayer) .filter(key => { - // filter by compatible runtimes - return isRuntime(runtimeValue).inRuntimes(functionMeta[key].runtimes || getLayerRuntimes(key)); + // filter by compatible runtimes - unless no runtimes are present for the given Lambda layer + // since any Lambda function can depend on /opt folder content if there is no runtime. + const runtimes = functionMeta[key].runtimes || getLayerRuntimes(key); + return Array.isArray(runtimes) && (_.isEmpty(runtimes) || isRuntime(runtimeValue).inRuntimes(runtimes)); }); if (layerOptions.length === 0) { @@ -49,9 +52,19 @@ export const askLayerSelection = async ( askArnQuestion: true, }; } + + const disabledMessage = 'Layer requires migration. Run "amplify function update" and choose this layer to migrate.'; const currentResourceNames = filterProjectLayers(previousSelections).map(sel => (sel as ProjectLayer).resourceName); - const choices = layerOptions.map(op => ({ name: op, checked: currentResourceNames.includes(op) })); - choices.unshift({ name: provideExistingARNsPrompt, checked: previousSelections.map(sel => sel.type).includes('ExternalLayer') }); + const choices = layerOptions.map(op => ({ + name: op, + checked: currentResourceNames.includes(op), + disabled: getLegacyLayerState(op) !== LegacyState.NOT_LEGACY ? disabledMessage : false, + })); + choices.unshift({ + name: provideExistingARNsPrompt, + checked: previousSelections.map(sel => sel.type).includes('ExternalLayer'), + disabled: false, + }); const layerSelectionQuestion: CheckboxQuestion = { type: 'checkbox', diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerConfiguration.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerConfiguration.ts index 81b6397d1bd..47414152306 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerConfiguration.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerConfiguration.ts @@ -1,8 +1,9 @@ import { $TSAny, $TSObject, JSONUtilities, pathManager, recursiveOmit, stateManager } from 'amplify-cli-core'; import _ from 'lodash'; import * as path from 'path'; -import { ephemeralField, deleteVersionsField, layerConfigurationFileName, updateVersionPermissionsField } from './constants'; +import { deleteVersionsField, ephemeralField, layerConfigurationFileName, updateVersionPermissionsField } from './constants'; import { categoryName } from '../../../constants'; +import { getLegacyLayerState, LegacyState, readLegacyRuntimes } from './layerMigrationUtils'; import { LayerParameters, LayerPermission, LayerRuntime, PermissionEnum } from './layerParams'; export type LayerConfiguration = Pick; @@ -24,7 +25,16 @@ export function getLayerConfiguration(layerName: string) { } export function getLayerRuntimes(layerName: string) { - return getLayerConfiguration(layerName).runtimes; + try { + return getLayerConfiguration(layerName).runtimes; + } catch (e) { + // File might not exist for layers that need to be migrated + const legacyState = getLegacyLayerState(layerName); + if (legacyState !== LegacyState.NOT_LEGACY) { + return readLegacyRuntimes(layerName, legacyState); + } + throw e; + } } export function saveLayerRuntimes(layerDirPath: string, runtimes: LayerRuntime[] = []) { diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerMigrationUtils.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerMigrationUtils.ts index 8776753922a..68acfbdcfd0 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerMigrationUtils.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/layerMigrationUtils.ts @@ -9,6 +9,12 @@ import { loadPluginFromFactory } from './functionPluginLoader'; import { writeLayerConfigurationFile } from './layerConfiguration'; import { defaultLayerPermission, LayerPermission, LayerRuntime, PermissionEnum } from './layerParams'; +export const enum LegacyState { + NOT_LEGACY, + MULTI_ENV_LEGACY, + SINGLE_ENV_LEGACY, +} + export const enum LegacyPermissionEnum { AwsAccounts = 'awsAccounts', AwsOrg = 'awsOrg', @@ -32,17 +38,16 @@ type LegacyVersionMap = { }; }; -const enum LegacyState { - NOT_LEGACY, - MULTI_ENV_LEGACY, - SINGLE_ENV_LEGACY, -} +type LegacyLayerParametersJson = { + [layerVersionMapKey]: LegacyVersionMap; + runtimes: LegacyRuntime[]; +}; const layerVersionMapKey = 'layerVersionMap'; export async function migrateLegacyLayer(context: $TSContext, layerName: string): Promise { const layerDirPath = pathManager.getResourceDirectoryPath(undefined, categoryName, layerName); - const legacyState = getLegacyLayerState(layerName, layerDirPath); + const legacyState = getLegacyLayerState(layerName); if (legacyState === LegacyState.NOT_LEGACY) { return false; @@ -69,13 +74,10 @@ This change requires a migration. Amplify will create a new Lambda layer version let layerVersionMap: LegacyVersionMap; if (legacyState === LegacyState.MULTI_ENV_LEGACY) { - legacyRuntimeArray = JSONUtilities.readJson(path.join(layerDirPath, LegacyFilename.layerRuntimes)); + legacyRuntimeArray = readLegacyRuntimes(layerName, legacyState); layerVersionMap = stateManager.getMeta()?.[categoryName]?.[layerName]?.[layerVersionMapKey] ?? {}; } else { - ({ layerVersionMap, runtimes: legacyRuntimeArray } = JSONUtilities.readJson<{ - [layerVersionMapKey]: LegacyVersionMap; - runtimes: LegacyRuntime[]; - }>(path.join(layerDirPath, LegacyFilename.layerParameters))); + ({ layerVersionMap, runtimes: legacyRuntimeArray } = readLegacyLayerParametersJson(layerDirPath)); layerConfiguration.nonMultiEnv = true; } @@ -140,7 +142,8 @@ This change requires a migration. Amplify will create a new Lambda layer version return true; } -function getLegacyLayerState(layerName: string, layerDirPath: string): LegacyState { +export function getLegacyLayerState(layerName: string): LegacyState { + const layerDirPath = pathManager.getResourceDirectoryPath(undefined, categoryName, layerName); if (fs.existsSync(path.join(layerDirPath, LegacyFilename.layerParameters))) { return LegacyState.SINGLE_ENV_LEGACY; } @@ -157,20 +160,17 @@ function getLegacyLayerState(layerName: string, layerDirPath: string): LegacySta ${chalk.red('Ensure your layer content is backed up!')}`); } -function migrateAmplifyProjectFiles(layerName: string, latestLegacyHash: string, envName?: string) { - const projectRoot = pathManager.findProjectRoot(); - removeLayerFromTeamProviderInfo(envName, layerName, projectRoot); - const meta = stateManager.getMeta(projectRoot); - - if (meta?.[categoryName]?.[layerName]?.[layerVersionMapKey]) { - meta[categoryName][layerName][layerVersionMapKey] = undefined; +export function readLegacyRuntimes(layerName: string, legacyState: LegacyState): LegacyRuntime[] { + const layerDirPath = pathManager.getResourceDirectoryPath(undefined, categoryName, layerName); + if (legacyState === LegacyState.SINGLE_ENV_LEGACY) { + return readLegacyLayerParametersJson(layerDirPath).runtimes; + } + if (legacyState === LegacyState.MULTI_ENV_LEGACY) { + return JSONUtilities.readJson(path.join(layerDirPath, LegacyFilename.layerRuntimes)); } - - _.set(meta, [categoryName, layerName, versionHash], latestLegacyHash); - stateManager.setMeta(projectRoot, meta); } -export function removeLayerFromTeamProviderInfo(envName: string, layerName: string, projectRoot?: string) { +export function removeLayerFromTeamProviderInfo(projectRoot: string | undefined, envName: string, layerName: string) { const nonCfnDataKey = 'nonCFNdata'; const teamProviderInfo = stateManager.getTeamProviderInfo(projectRoot); @@ -183,3 +183,20 @@ export function removeLayerFromTeamProviderInfo(envName: string, layerName: stri } stateManager.setTeamProviderInfo(projectRoot, teamProviderInfo); } + +function readLegacyLayerParametersJson(layerDirPath: string) { + return JSONUtilities.readJson(path.join(layerDirPath, LegacyFilename.layerParameters)); +} + +function migrateAmplifyProjectFiles(layerName: string, latestLegacyHash: string, envName?: string) { + const projectRoot = pathManager.findProjectRoot(); + removeLayerFromTeamProviderInfo(projectRoot, envName, layerName); + const meta = stateManager.getMeta(projectRoot); + + if (meta?.[categoryName]?.[layerName]?.[layerVersionMapKey]) { + meta[categoryName][layerName][layerVersionMapKey] = undefined; + } + + _.set(meta, [categoryName, layerName, versionHash], latestLegacyHash); + stateManager.setMeta(projectRoot, meta); +} diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/storeResources.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/storeResources.ts index 998952142f5..ddae3a95f74 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/storeResources.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/utils/storeResources.ts @@ -86,7 +86,7 @@ export const updateLayerArtifacts = async ( export function removeLayerArtifacts(context: $TSContext, layerName: string) { if (isMultiEnvLayer(layerName)) { - removeLayerFromTeamProviderInfo(context.amplify.getEnvInfo().envName, layerName); + removeLayerFromTeamProviderInfo(undefined, context.amplify.getEnvInfo().envName, layerName); } } diff --git a/packages/amplify-e2e-core/src/categories/lambda-function.ts b/packages/amplify-e2e-core/src/categories/lambda-function.ts index 319bd2d0a4c..210dc3e31f9 100644 --- a/packages/amplify-e2e-core/src/categories/lambda-function.ts +++ b/packages/amplify-e2e-core/src/categories/lambda-function.ts @@ -142,7 +142,7 @@ export type CoreFunctionSettings = { expectFailure?: boolean; additionalPermissions?: any; schedulePermissions?: any; - layerOptions?: any; + layerOptions?: LayerOptions; environmentVariables?: any; secretsConfig?: AddSecretInput | UpdateSecretInput | DeleteSecretInput; triggerType?: string; @@ -335,7 +335,7 @@ export const functionBuild = (cwd: string, settings: any): Promise => { }); }; -export const selectRuntime = (chain: any, runtime: FunctionRuntimes) => { +export const selectRuntime = (chain: ExecutionContext, runtime: FunctionRuntimes) => { const runtimeName = getRuntimeDisplayName(runtime); chain.wait('Choose the runtime that you want to use:'); @@ -345,7 +345,7 @@ export const selectRuntime = (chain: any, runtime: FunctionRuntimes) => { singleSelect(chain, runtimeName, runtimeChoices); }; -export const selectTemplate = (chain: any, functionTemplate: string, runtime: FunctionRuntimes) => { +export const selectTemplate = (chain: ExecutionContext, functionTemplate: string, runtime: FunctionRuntimes) => { const templateChoices = getTemplateChoices(runtime); chain.wait('Choose the function template that you want to use'); diff --git a/packages/amplify-e2e-core/src/categories/lambda-layer.ts b/packages/amplify-e2e-core/src/categories/lambda-layer.ts index 7eaa640f7d8..17f1f2867d6 100644 --- a/packages/amplify-e2e-core/src/categories/lambda-layer.ts +++ b/packages/amplify-e2e-core/src/categories/lambda-layer.ts @@ -379,7 +379,7 @@ function waitForLayerSuccessPrintout( if (settings?.runtimes?.length > 0) { chain - .wait(path.join('amplify', 'backend', 'function', settings.projName + settings.layerName)) + .wait(path.join('amplify', 'backend', 'function', (settings.projName || '') + settings.layerName)) .wait('Next steps:') .wait('Move your libraries to the following folder:'); diff --git a/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts b/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts index 09a5471b6f9..81d60a69dc6 100644 --- a/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts +++ b/packages/amplify-migration-tests/src/__tests__/migration_tests/lambda-layer-migration/layer-migration.test.ts @@ -1,4 +1,5 @@ import { + addFunction, amplifyPushAuth, amplifyPushLayer, amplifyStatus, @@ -10,6 +11,7 @@ import { LayerRuntime, LayerPermissionChoice, removeLayerVersion, + updateFunction, updateLayer, } from 'amplify-e2e-core'; import { v4 as uuid } from 'uuid'; @@ -99,13 +101,11 @@ describe('test lambda layer migration flow introduced in v5.0.0', () => { }); it('migrate layer in Update state with "amplify push"', async () => { - const { projectName: projName } = getProjectConfig(projRoot); const [shortId] = uuid().split('-'); const layerName = `test${shortId}`; const layerRuntime: LayerRuntime = 'nodejs'; const layerSettings = { layerName, - projName, runtimes: [layerRuntime], }; @@ -118,13 +118,11 @@ describe('test lambda layer migration flow introduced in v5.0.0', () => { }); it('migrate layer in No Change state with "amplify update function" by updating permissions', async () => { - const { projectName: projName } = getProjectConfig(projRoot); const [shortId] = uuid().split('-'); const layerName = `test${shortId}`; const layerRuntime: LayerRuntime = 'nodejs'; const layerSettings = { layerName, - projName, runtimes: [layerRuntime], }; @@ -147,12 +145,10 @@ describe('test lambda layer migration flow introduced in v5.0.0', () => { }); it('migrates a layer with no runtime', async () => { - const { projectName: projName } = getProjectConfig(projRoot); const [shortId] = uuid().split('-'); const layerName = `test${shortId}`; const layerSettings = { layerName, - projName, runtimes: [], }; @@ -166,4 +162,21 @@ describe('test lambda layer migration flow introduced in v5.0.0', () => { expect(validateLayerConfigFilesMigrated(projRoot, layerName)).toBe(true); }); + + it('handle add and update function when legacy layer is present', async () => { + const [shortId] = uuid().split('-'); + const layerName = `test${shortId}`; + const layerRuntime: LayerRuntime = 'nodejs'; + const functionSettings = { + testingWithLatestCodebase: true, + layerOptions: { + select: [], + expectedListOptions: [layerName], + }, + }; + + await legacyAddLayer(projRoot, { layerName: layerName, runtimes: [layerRuntime] }); + await addFunction(projRoot, { ...functionSettings, functionTemplate: 'Hello World' }, layerRuntime); + await updateFunction(projRoot, functionSettings, layerRuntime); + }); }); diff --git a/packages/amplify-migration-tests/src/migration-helpers/legacy-lambda-layer.ts b/packages/amplify-migration-tests/src/migration-helpers/legacy-lambda-layer.ts index fb35ee92e57..88de42f04fb 100644 --- a/packages/amplify-migration-tests/src/migration-helpers/legacy-lambda-layer.ts +++ b/packages/amplify-migration-tests/src/migration-helpers/legacy-lambda-layer.ts @@ -20,7 +20,6 @@ export function legacyAddLayer( permissions?: LayerPermissionChoice[]; accountId?: string; orgId?: string; - projName: string; runtimes: LayerRuntime[]; }, ): Promise { From e18b70a771a36009e0681b35bf31dbe8e8c64dcc Mon Sep 17 00:00:00 2001 From: Yathi <511386+yuth@users.noreply.github.com> Date: Mon, 12 Jul 2021 11:41:49 -0700 Subject: [PATCH 014/125] ci: add support for automatic tagged release (#7691) Do an automatic tagged NPM release when a branch name is prefixed with tagged-release/ --- .circleci/config.base.yml | 51 ++++++++++++++++++++------------------- .circleci/config.yml | 51 ++++++++++++++++++++------------------- .circleci/publish.sh | 24 ++++++++++++++++++ package.json | 1 + 4 files changed, 77 insertions(+), 50 deletions(-) create mode 100755 .circleci/publish.sh diff --git a/.circleci/config.base.yml b/.circleci/config.base.yml index 7ea00926f8a..c6a9a169749 100644 --- a/.circleci/config.base.yml +++ b/.circleci/config.base.yml @@ -526,7 +526,7 @@ jobs: path: /root/aws-amplify-cypress-api/cypress/screenshots deploy: - <<: *defaults + <<: *node12 steps: - attach_workspace: at: ./ @@ -539,13 +539,7 @@ jobs: - run: name: Publish Amplify CLI command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - git config --global user.email $GITHUB_EMAIL - git config --global user.name $GITHUB_USER - npm run publish:$CIRCLE_BRANCH - else - echo "Skipping deploy." - fi + bash ./.circleci/publish.sh - run: *scan_e2e_test_artifacts github_prerelease: <<: *node12 @@ -694,8 +688,8 @@ workflows: branches: only: - master - - func-env-vars-secrets - - iterative-update + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - mock_e2e_tests @@ -707,8 +701,9 @@ workflows: branches: only: - master - - func-env-vars-secrets - beta + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - mock_e2e_tests @@ -717,12 +712,10 @@ workflows: branches: only: - master - - func-env-vars-secrets - beta - - backendManager - - iterative-update - release - - compute-functions + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - build_pkg_binaries: @@ -736,6 +729,8 @@ workflows: branches: only: - master + - /tagged-release\/.*/ + - /run-e2e\/*./ - amplify_e2e_tests: context: - amplify-ecr-image-pull @@ -748,9 +743,8 @@ workflows: branches: only: - master - - func-env-vars-secrets - - compute-functions - - iterative-update + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - publish_to_local_registry - done_with_node_e2e_tests: @@ -768,6 +762,8 @@ workflows: branches: only: - master + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - done_with_node_e2e_tests - build_pkg_binaries @@ -784,6 +780,8 @@ workflows: branches: only: - master + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_v4: @@ -796,7 +794,8 @@ workflows: branches: only: - master - - func-env-vars-secrets + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_v4_30_0: @@ -809,10 +808,8 @@ workflows: branches: only: - master - - func-env-vars-secrets - - graphqlschemae2e - - feat-import - - test-fix-status + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_non_multi_env_layers: @@ -825,7 +822,8 @@ workflows: branches: only: - master - - func-env-vars-secrets + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_multi_env_layers: @@ -838,7 +836,8 @@ workflows: branches: only: - master - - func-env-vars-secrets + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_console_integration_tests: @@ -907,6 +906,8 @@ workflows: - release - master - beta + - /tagged-release\/.*/ + - /tagged-release-without-e2e-tests\/.*/ - github_release: context: github-publish requires: diff --git a/.circleci/config.yml b/.circleci/config.yml index d88bc196f25..043699f14a3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -549,7 +549,7 @@ jobs: path: /root/aws-amplify-cypress-api/cypress/screenshots deploy: working_directory: ~/repo - docker: *ref_1 + docker: *ref_0 resource_class: large steps: - attach_workspace: @@ -563,13 +563,7 @@ jobs: - run: name: Publish Amplify CLI command: | - if [ -z "$CIRCLE_PULL_REQUEST" ]; then - git config --global user.email $GITHUB_EMAIL - git config --global user.name $GITHUB_USER - npm run publish:$CIRCLE_BRANCH - else - echo "Skipping deploy." - fi + bash ./.circleci/publish.sh - run: *ref_4 github_prerelease: working_directory: ~/repo @@ -2057,8 +2051,8 @@ workflows: branches: only: - master - - func-env-vars-secrets - - iterative-update + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - mock_e2e_tests @@ -2070,8 +2064,9 @@ workflows: branches: only: - master - - func-env-vars-secrets - beta + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - mock_e2e_tests @@ -2080,12 +2075,10 @@ workflows: branches: only: - master - - func-env-vars-secrets - beta - - backendManager - - iterative-update - release - - compute-functions + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - build_pkg_binaries: @@ -2099,6 +2092,8 @@ workflows: branches: only: - master + - /tagged-release\/.*/ + - /run-e2e\/*./ - done_with_node_e2e_tests: requires: - analytics-amplify_e2e_tests @@ -2169,6 +2164,8 @@ workflows: branches: only: - master + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_v4: @@ -2181,7 +2178,8 @@ workflows: branches: only: - master - - func-env-vars-secrets + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_v4_30_0: @@ -2194,10 +2192,8 @@ workflows: branches: only: - master - - func-env-vars-secrets - - graphqlschemae2e - - feat-import - - test-fix-status + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_non_multi_env_layers: @@ -2210,7 +2206,8 @@ workflows: branches: only: - master - - func-env-vars-secrets + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_migration_tests_multi_env_layers: @@ -2223,7 +2220,8 @@ workflows: branches: only: - master - - func-env-vars-secrets + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - build - amplify_console_integration_tests: @@ -2291,6 +2289,8 @@ workflows: - release - master - beta + - /tagged-release\/.*/ + - /tagged-release-without-e2e-tests\/.*/ - github_release: context: github-publish requires: @@ -2311,9 +2311,8 @@ workflows: branches: only: - master - - func-env-vars-secrets - - compute-functions - - iterative-update + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - publish_to_local_registry - schema-auth-6-amplify_e2e_tests: @@ -2766,6 +2765,8 @@ workflows: branches: only: - master + - /tagged-release\/.*/ + - /run-e2e\/*./ requires: - done_with_node_e2e_tests - build_pkg_binaries diff --git a/.circleci/publish.sh b/.circleci/publish.sh new file mode 100755 index 00000000000..64ef7196d76 --- /dev/null +++ b/.circleci/publish.sh @@ -0,0 +1,24 @@ +#!/bin/bash -e +if [ -z "$CIRCLE_PULL_REQUEST" ]; then + git config --global user.email $GITHUB_EMAIL + git config --global user.name $GITHUB_USER + if [[ "$CIRCLE_BRANCH" =~ ^tagged-release ]]; then + if [[ "$CIRCLE_BRANCH" =~ ^tagged-release-without-e2e-tests\/.* ]]; then + # Remove tagged-release-without-e2e-tests/ + export NPM_TAG="${CIRCLE_BRANCH/tagged-release-without-e2e-tests\//}" + elif [[ "$CIRCLE_BRANCH" =~ ^tagged-release\/.* ]]; then + # Remove tagged-release/ + export NPM_TAG="${CIRCLE_BRANCH/tagged-release\//}" + fi + if [ -z "$NPM_TAG" ]; then + echo "Tag name is missing. Name your banch with either tagged-release/ or tagged-release-without-e2e-tests/" + exit 1 + fi + echo "Publishing to NPM with tag $NPM_TAG" + yarn publish:tag + else + yarn publish:$CIRCLE_BRANCH + fi +else + echo "Skipping deploy." +fi \ No newline at end of file diff --git a/package.json b/package.json index 680f7c32fcb..6becb11adff 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "pkg-all-local": "yarn verdaccio-start && yarn verdaccio-connect && yarn publish-to-verdaccio && yarn pkg-all && yarn verdaccio-disconnect", "publish:master": "lerna publish --canary --force-publish --preid=alpha --exact --include-merged-tags --conventional-prerelease --no-verify-access --yes", "publish:beta": "lerna publish --exact --dist-tag=beta --preid=beta --conventional-commits --conventional-prerelease --message 'chore(release): Publish [ci skip]' --no-verify-access --yes", + "publish:tag": "lerna publish --exact --dist-tag=$NPM_TAG --preid=$NPM_TAG --conventional-commits --conventional-prerelease --message 'chore(release): Publish tagged release $NPM_TAG [ci skip]' --no-verify-access --yes", "publish:release": "lerna publish --conventional-commits --exact --yes --message 'chore(release): Publish [ci skip]' --no-verify-access", "postpublish:release": "git fetch . release:master && git push origin master", "yarn-use-bash": "yarn config set script-shell /bin/bash", From 7471c5fcc86af0e17a967066a388f67891f93355 Mon Sep 17 00:00:00 2001 From: Attila Hajdrik Date: Mon, 12 Jul 2021 11:42:17 -0700 Subject: [PATCH 015/125] fix: #7441 - init from git prompts for credentials twice (#7682) --- .../secrets/ssmClientWrapper.ts | 15 +++++-- .../amplify-helpers/delete-project.ts | 4 +- .../amplify-helpers/remove-env-from-cloud.ts | 4 +- .../src/init-steps/preInitSetup.ts | 18 +++++++- .../src/amplify-service-manager.js | 19 +++++---- .../src/amplify-service-migrate.js | 8 ++-- .../src/attach-backend.js | 28 ++++++------- .../src/configuration-manager.ts | 41 ++++++++++++++----- .../src/initializer.ts | 6 +-- .../src/setup-new-user.js | 26 ++++++------ .../src/system-config-manager.ts | 34 +++++++-------- .../src/utils/admin-helpers.ts | 6 ++- .../src/utils/auth-types.ts | 2 +- .../lambda/populate-lambda-mock-env-vars.ts | 8 ++-- 14 files changed, 136 insertions(+), 83 deletions(-) diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/secrets/ssmClientWrapper.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/secrets/ssmClientWrapper.ts index e5979795d0a..00a08df2b27 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/secrets/ssmClientWrapper.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/secrets/ssmClientWrapper.ts @@ -102,8 +102,15 @@ export class SSMClientWrapper { const getSSMClient = async (context: $TSContext) => { const spinner = ora('Initializing SSM Client'); - spinner.start(); - const { client } = await context.amplify.invokePluginMethod(context, 'awscloudformation', undefined, 'getConfiguredSSMClient', [context]); - spinner.stop(); - return client as aws.SSM; + try { + spinner.start(); + + const { client } = await context.amplify.invokePluginMethod(context, 'awscloudformation', undefined, 'getConfiguredSSMClient', [ + context, + ]); + + return client as aws.SSM; + } finally { + spinner.stop(); + } }; diff --git a/packages/amplify-cli/src/extensions/amplify-helpers/delete-project.ts b/packages/amplify-cli/src/extensions/amplify-helpers/delete-project.ts index c46f38dcb47..e76ef9d19c2 100644 --- a/packages/amplify-cli/src/extensions/amplify-helpers/delete-project.ts +++ b/packages/amplify-cli/src/extensions/amplify-helpers/delete-project.ts @@ -35,10 +35,10 @@ export async function deleteProject(context) { } } } catch (ex) { - spinner.fail('Project delete failed'); + spinner.fail('Project delete failed.'); throw ex; } - spinner.succeed('Project deleted in the cloud'); + spinner.succeed('Project deleted in the cloud.'); // Remove amplify dir const { frontend } = context.amplify.getProjectConfig(); const frontendPlugins = getFrontendPlugins(context); diff --git a/packages/amplify-cli/src/extensions/amplify-helpers/remove-env-from-cloud.ts b/packages/amplify-cli/src/extensions/amplify-helpers/remove-env-from-cloud.ts index 5c1b82792fd..92b1da9de63 100644 --- a/packages/amplify-cli/src/extensions/amplify-helpers/remove-env-from-cloud.ts +++ b/packages/amplify-cli/src/extensions/amplify-helpers/remove-env-from-cloud.ts @@ -8,7 +8,7 @@ export async function removeEnvFromCloud(context, envName, deleteS3) { const providerPlugins = getProviderPlugins(context); const providerPromises: (() => Promise)[] = []; context.print.info(''); - context.print.info(`Deleting env:${envName}`); + context.print.info(`Deleting env: ${envName}.`); // Pinpoint attaches an IAM policy to several roles, which blocks CFN from // deleting the roles. Work around that by deleting Pinpoint first. @@ -28,7 +28,7 @@ export async function removeEnvFromCloud(context, envName, deleteS3) { await raiseIntenralOnlyPostEnvRemoveEvent(context, envName); } catch (e) { context.print.info(''); - context.print.error(`Error in deleting env:${envName}`); + context.print.error(`Error occurred while deleting env: ${envName}.`); context.print.info(e.message); throw e; } diff --git a/packages/amplify-cli/src/init-steps/preInitSetup.ts b/packages/amplify-cli/src/init-steps/preInitSetup.ts index 31da845c098..51cd0d4a103 100644 --- a/packages/amplify-cli/src/init-steps/preInitSetup.ts +++ b/packages/amplify-cli/src/init-steps/preInitSetup.ts @@ -1,4 +1,4 @@ -import { $TSContext, exitOnNextTick, getPackageManager, NonEmptyDirectoryError } from 'amplify-cli-core'; +import { $TSContext, exitOnNextTick, getPackageManager, NonEmptyDirectoryError, pathManager } from 'amplify-cli-core'; import { execSync } from 'child_process'; import * as fs from 'fs-extra'; import * as url from 'url'; @@ -12,6 +12,7 @@ export async function preInitSetup(context: $TSContext) { await validateGithubRepo(context, repoUrl); await cloneRepo(context, repoUrl); + cleanAmplifyArtifacts(); await installPackage(); await setLocalEnvDefaults(context); } @@ -93,5 +94,18 @@ async function setLocalEnvDefaults(context: $TSContext) { context.exeInfo.inputParams.amplify.envName = envName; - await generateLocalEnvInfoFile(context); + generateLocalEnvInfoFile(context); +} + +/** + * After cloning a project, remove the environment specific, perhaps accidentally checked in Amplify state files + * to make sure further commands will run correctly, like 'amplify delete' + */ +function cleanAmplifyArtifacts() { + const projectPath = process.cwd(); + + fs.removeSync(pathManager.getAmplifyMetaFilePath(projectPath)); + fs.removeSync(pathManager.getTeamProviderInfoFilePath(projectPath)); + fs.removeSync(pathManager.getLocalAWSInfoFilePath(projectPath)); + fs.removeSync(pathManager.getLocalEnvFilePath(projectPath)); } diff --git a/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js b/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js index 03dd70c8a55..d72fb0b80d2 100644 --- a/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js +++ b/packages/amplify-provider-awscloudformation/src/amplify-service-manager.js @@ -12,13 +12,13 @@ const { loadConfigurationForEnv } = require('./configuration-manager'); const logger = fileLogger('amplify-service-manager'); async function init(amplifyServiceParams) { - const { context, awsConfig, projectName, envName, stackName } = amplifyServiceParams; + const { context, awsConfigInfo, projectName, envName, stackName } = amplifyServiceParams; let amplifyAppId; let verifiedStackName = stackName; let deploymentBucketName = `${stackName}-deployment`; - const amplifyClient = await getConfiguredAmplifyClient(context, awsConfig); + const amplifyClient = await getConfiguredAmplifyClient(context, awsConfigInfo); if (!amplifyClient) { // This happens when the Amplify service is not available in the region return { @@ -74,7 +74,7 @@ async function init(amplifyServiceParams) { for (let env of envList) { if ( env !== envName && - teamProviderInfo[env][ProviderName].Region === awsConfig.region && + teamProviderInfo[env][ProviderName].Region === awsConfigInfo.region && teamProviderInfo[env][ProviderName][AmplifyAppIdLabel] && !appIdsInTheSameLocalProjectAndRegion.includes(teamProviderInfo[env][ProviderName][AmplifyAppIdLabel]) ) { @@ -108,7 +108,7 @@ async function init(amplifyServiceParams) { if (appIdsInTheSameLocalProjectAndRegion.length === 1) { amplifyAppId = appIdsInTheSameLocalProjectAndRegion[0]; // eslint-disable-line } else if (appIdsInTheSameLocalProjectAndRegion.length > 1) { - context.print.info(`Your project is associated with multiple Amplify Service Apps in the region ${awsConfig.region}`); + context.print.info(`Your project is associated with multiple Amplify Service Apps in the region ${awsConfigInfo.region}`); amplifyAppId = await SelectFromExistingAppId(context, appIdsInTheSameLocalProjectAndRegion); } } @@ -204,7 +204,7 @@ async function init(amplifyServiceParams) { }; } -async function deleteEnv(context, envName, awsConfig) { +async function deleteEnv(context, envName, awsConfigInfo) { if (stateManager.teamProviderInfoExists()) { const teamProviderInfo = stateManager.getTeamProviderInfo(); if ( @@ -213,7 +213,7 @@ async function deleteEnv(context, envName, awsConfig) { teamProviderInfo[envName][ProviderName][AmplifyAppIdLabel] ) { const envConfig = await loadConfigurationForEnv(context, envName); - const amplifyClient = await getConfiguredAmplifyClient(context, { ...awsConfig, ...envConfig }); + const amplifyClient = await getConfiguredAmplifyClient(context, { ...awsConfigInfo, ...envConfig }); if (!amplifyClient) { // This happens when the Amplify service is not available in the region return; @@ -235,7 +235,12 @@ async function deleteEnv(context, envName, awsConfig) { await amplifyClient.deleteBackendEnvironment(deleteEnvParams).promise(); } catch (ex) { log(ex); - throw ex; + + if (ex.code === 'NotFoundException') { + context.print.warning(ex.message); + } else { + throw ex; + } } } } diff --git a/packages/amplify-provider-awscloudformation/src/amplify-service-migrate.js b/packages/amplify-provider-awscloudformation/src/amplify-service-migrate.js index 4152d65e860..ff2f00ba4df 100644 --- a/packages/amplify-provider-awscloudformation/src/amplify-service-migrate.js +++ b/packages/amplify-provider-awscloudformation/src/amplify-service-migrate.js @@ -11,7 +11,7 @@ async function run(context) { let projectDetails; let currentAmplifyMetaFilePath; let currentAmplifyMeta; - let awsConfig; + let awsConfigInfo; let isProjectFullySetUp = false; @@ -19,7 +19,7 @@ async function run(context) { projectDetails = context.amplify.getProjectDetails(); currentAmplifyMetaFilePath = context.amplify.pathManager.getCurrentAmplifyMetaFilePath(); currentAmplifyMeta = context.amplify.readJsonFile(currentAmplifyMetaFilePath); - awsConfig = await configurationManager.getAwsConfig(context); + awsConfigInfo = await configurationManager.getAwsConfig(context); isProjectFullySetUp = true; } catch (e) { isProjectFullySetUp = false; @@ -38,10 +38,10 @@ async function run(context) { return; } - const amplifyClient = await getConfiguredAmplifyClient(context, awsConfig); + const amplifyClient = await getConfiguredAmplifyClient(context, awsConfigInfo); if (!amplifyClient) { // This happens when the Amplify service is not available in the region - const message = `Amplify service is not available in the region ${awsConfig.region ? awsConfig.region : ''}`; + const message = `Amplify service is not available in the region ${awsConfigInfo.region ? awsConfigInfo.region : ''}`; context.print.error(message); throw new Error(message); } diff --git a/packages/amplify-provider-awscloudformation/src/attach-backend.js b/packages/amplify-provider-awscloudformation/src/attach-backend.js index ba56cfacb52..e423a526775 100644 --- a/packages/amplify-provider-awscloudformation/src/attach-backend.js +++ b/packages/amplify-provider-awscloudformation/src/attach-backend.js @@ -18,7 +18,7 @@ const logger = fileLogger('attach-backend'); async function run(context) { let appId; - let awsConfig; + let awsConfigInfo; let isAdminApp = false; try { appId = resolveAppId(context); @@ -44,20 +44,20 @@ async function run(context) { } if (isAdminApp) { - context.exeInfo.awsConfig = { + context.exeInfo.awsConfigInfo = { configLevel: 'amplifyAdmin', config: {}, }; - awsConfig = await configurationManager.loadConfigurationForEnv(context, envName, appId); + awsConfigInfo = await configurationManager.loadConfigurationForEnv(context, envName, appId); } else { await configurationManager.init(context); - awsConfig = await configurationManager.getAwsConfig(context); + awsConfigInfo = await configurationManager.getAwsConfig(context); } - const amplifyClient = await getConfiguredAmplifyClient(context, awsConfig); + const amplifyClient = await getConfiguredAmplifyClient(context, awsConfigInfo); if (!amplifyClient) { // This happens when the Amplify service is not available in the region - const region = awsConfig && awsConfig.region ? awsConfig.region : ''; + const region = awsConfigInfo && awsConfigInfo.region ? awsConfigInfo.region : ''; const message = `Amplify service is not available in the region ${region}`; context.print.error(message); throw new Error(message); @@ -74,15 +74,15 @@ async function run(context) { const backendEnv = await getBackendEnv(context, amplifyClient, amplifyApp); - await downloadBackend(context, backendEnv, awsConfig); - const currentAmplifyMeta = await ensureAmplifyMeta(context, amplifyApp, awsConfig); + await downloadBackend(context, backendEnv, awsConfigInfo); + const currentAmplifyMeta = await ensureAmplifyMeta(context, amplifyApp, awsConfigInfo); context.exeInfo.projectConfig.projectName = amplifyApp.name; context.exeInfo.localEnvInfo.envName = backendEnv.environmentName; context.exeInfo.teamProviderInfo[backendEnv.environmentName] = currentAmplifyMeta.providers; } -async function ensureAmplifyMeta(context, amplifyApp, awsConfig) { +async function ensureAmplifyMeta(context, amplifyApp, awsConfigInfo) { // check if appId is present in the provider section of the metadata // if not, it's a migration case and we need to // 1. insert the appId @@ -99,15 +99,15 @@ async function ensureAmplifyMeta(context, amplifyApp, awsConfig) { fs.writeFileSync(amplifyMetaFilePath, jsonString, 'utf8'); const { DeploymentBucketName } = currentAmplifyMeta.providers[constants.ProviderName]; - await storeArtifactsForAmplifyService(context, awsConfig, DeploymentBucketName); + await storeArtifactsForAmplifyService(context, awsConfigInfo, DeploymentBucketName); } return currentAmplifyMeta; } -async function storeArtifactsForAmplifyService(context, awsConfig, deploymentBucketName) { +async function storeArtifactsForAmplifyService(context, awsConfigInfo, deploymentBucketName) { const projectPath = process.cwd(); - const s3Client = new aws.S3(awsConfig); + const s3Client = new aws.S3(awsConfigInfo); const amplifyMetaFilePath = context.amplify.pathManager.getCurrentAmplifyMetaFilePath(projectPath); const backendConfigFilePath = context.amplify.pathManager.getCurrentBackendConfigFilePath(projectPath); await uploadFile(s3Client, deploymentBucketName, amplifyMetaFilePath); @@ -297,7 +297,7 @@ async function getBackendEnv(context, amplifyClient, amplifyApp) { throw ex; } -async function downloadBackend(context, backendEnv, awsConfig) { +async function downloadBackend(context, backendEnv, awsConfigInfo) { if (!backendEnv) { return; } @@ -308,7 +308,7 @@ async function downloadBackend(context, backendEnv, awsConfig) { const backendDir = context.amplify.pathManager.getBackendDirPath(projectPath); const zipFileName = constants.S3BackendZipFileName; - const s3Client = new aws.S3(awsConfig); + const s3Client = new aws.S3(awsConfigInfo); const deploymentBucketName = backendEnv.deploymentArtifacts; const params = { diff --git a/packages/amplify-provider-awscloudformation/src/configuration-manager.ts b/packages/amplify-provider-awscloudformation/src/configuration-manager.ts index ecd5df7b444..99152eb3b97 100644 --- a/packages/amplify-provider-awscloudformation/src/configuration-manager.ts +++ b/packages/amplify-provider-awscloudformation/src/configuration-manager.ts @@ -64,6 +64,11 @@ export async function init(context: $TSContext) { configLevel: 'project', config: { useProfile: false }, }; + } else if (authTypeConfig.type === 'general') { + context.exeInfo.awsConfigInfo = { + configLevel: 'general', + config: {}, + }; } else { context.exeInfo.awsConfigInfo = { configLevel: 'project', @@ -522,7 +527,7 @@ function getCurrentConfig(context: $TSContext) { } function getConfigForEnv(context: $TSContext, envName: string) { - const projectConfigInfo: ProjectConfig = context?.exeInfo?.awsConfig || { + const projectConfigInfo: ProjectConfig = context?.exeInfo?.awsConfigInfo || { configLevel: 'general', config: {}, }; @@ -599,11 +604,13 @@ function loadConfigFromPath(profilePath: string): AwsSdkConfig { export async function loadConfigurationForEnv(context: $TSContext, env: string, appId?: string): Promise { const { awsConfigInfo } = context.exeInfo || {}; + if (awsConfigInfo?.config?.accessKeyId && awsConfigInfo?.config?.secretAccessKey) { // Already loaded config if (!awsConfigInfo.region) { awsConfigInfo.region = resolveRegion(); } + return awsConfigInfo.config; } @@ -614,6 +621,7 @@ export async function loadConfigurationForEnv(context: $TSContext, env: string, if (authType.type === 'admin') { projectConfigInfo.configLevel = 'amplifyAdmin'; appId = appId || authType.appId; + try { awsConfig = await getTempCredsWithAdminTokens(context, appId); } catch (e) { @@ -632,6 +640,7 @@ export async function loadConfigurationForEnv(context: $TSContext, env: string, } else if (authType.type === 'accessKeys') { awsConfig = loadConfigFromPath(projectConfigInfo.config.awsConfigFilePath); } + return awsConfig; } @@ -649,6 +658,7 @@ export function resolveRegion(): string { // For details of how aws region is set, check the following link // https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-region.html let region: string; + if (process.env.AWS_REGION) { region = process.env.AWS_REGION; } @@ -659,6 +669,7 @@ export function resolveRegion(): string { const profileName = process.env.AWS_PROFILE || 'default'; region = systemConfigManager.getProfileRegion(profileName); } + return region; } @@ -694,6 +705,7 @@ async function newUserCheck(context: $TSContext) { function scanConfig(context: $TSContext) { let configSource: string = getConfigLevel(context); + if (!configSource) { const namedProfiles: $TSAny = systemConfigManager.getNamedProfiles(); if (namedProfiles && Object.keys(namedProfiles).length > 0) { @@ -715,6 +727,7 @@ function scanConfig(context: $TSContext) { function getConfigLevel(context: $TSContext): ProjectType { let configLevel: ProjectType; + try { const namedProfiles = systemConfigManager.getNamedProfiles(); const configInfoFilePath = pathManager.getLocalAWSInfoFilePath(); @@ -738,6 +751,7 @@ function getConfigLevel(context: $TSContext): ProjectType { } catch (e) { // no need to do anything } + return configLevel; } @@ -745,18 +759,19 @@ export async function getAwsConfig(context: $TSContext): Promise { const { awsConfigInfo } = context.exeInfo; const httpProxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; - let awsConfig: AwsSdkConfig; + let resultAWSConfigInfo: AwsSdkConfig; + if (awsConfigInfo.configLevel === 'project') { if (awsConfigInfo.config.useProfile) { try { - awsConfig = await systemConfigManager.getProfiledAwsConfig(context, awsConfigInfo.config.profileName); + resultAWSConfigInfo = await systemConfigManager.getProfiledAwsConfig(context, awsConfigInfo.config.profileName); } catch (e) { context.print.error(`Failed to get profile: ${e.message || e}`); await context.usageData.emitError(e); exitOnNextTick(1); } } else { - awsConfig = { + resultAWSConfigInfo = { accessKeyId: awsConfigInfo.config.accessKeyId, secretAccessKey: awsConfigInfo.config.secretAccessKey, region: awsConfigInfo.config.region, @@ -765,7 +780,7 @@ export async function getAwsConfig(context: $TSContext): Promise { } else if (awsConfigInfo.configLevel === 'amplifyAdmin') { const appId = resolveAppId(context); try { - awsConfig = await getTempCredsWithAdminTokens(context, appId); + resultAWSConfigInfo = await getTempCredsWithAdminTokens(context, appId); } catch (err) { context.print.error('Failed to fetch Amplify Admin credentials'); throw new Error(err); @@ -773,13 +788,13 @@ export async function getAwsConfig(context: $TSContext): Promise { } if (httpProxy) { - awsConfig = { - ...awsConfig, + resultAWSConfigInfo = { + ...resultAWSConfigInfo, httpOptions: { agent: proxyAgent(httpProxy) }, }; } - return awsConfig; + return resultAWSConfigInfo; } async function determineAuthFlow(context: $TSContext, projectConfig?: ProjectConfig): Promise { @@ -807,6 +822,12 @@ async function determineAuthFlow(context: $TSContext, projectConfig?: ProjectCon useProfile = useProfile ?? projectConfig?.config?.useProfile; profileName = profileName ?? projectConfig?.config?.profileName; + const generalCreds = projectConfig?.configLevel === 'general'; + + if (generalCreds) { + return { type: 'general' }; + } + if (useProfile && profileName) { return { type: 'profile', profileName }; } @@ -816,8 +837,8 @@ async function determineAuthFlow(context: $TSContext, projectConfig?: ProjectCon } if (projectConfig?.config?.awsConfigFilePath) { - const awsConfig = loadConfigFromPath(projectConfig.config.awsConfigFilePath); - return { ...awsConfig, type: 'accessKeys' }; + const awsConfigInfo = loadConfigFromPath(projectConfig.config.awsConfigFilePath); + return { ...awsConfigInfo, type: 'accessKeys' }; } let appId: string; diff --git a/packages/amplify-provider-awscloudformation/src/initializer.ts b/packages/amplify-provider-awscloudformation/src/initializer.ts index 03ddb87225a..80bd8fc6d9e 100644 --- a/packages/amplify-provider-awscloudformation/src/initializer.ts +++ b/packages/amplify-provider-awscloudformation/src/initializer.ts @@ -29,13 +29,13 @@ export async function run(context) { const timeStamp = `${moment().format('Hmmss')}`; const { envName = '' } = context.exeInfo.localEnvInfo; let stackName = normalizeStackName(`amplify-${projectName}-${envName}-${timeStamp}`); - const awsConfig = await configurationManager.getAwsConfig(context); + const awsConfigInfo = await configurationManager.getAwsConfig(context); await configurePermissionsBoundaryForInit(context); const amplifyServiceParams = { context, - awsConfig, + awsConfigInfo, projectName, envName, stackName, @@ -80,7 +80,7 @@ export async function run(context) { spinner.start('Initializing project in the cloud...'); try { - const cfnItem = await new Cloudformation(context, 'init', awsConfig); + const cfnItem = await new Cloudformation(context, 'init', awsConfigInfo); const stackDescriptionData = await cfnItem.createResourceStack(params); processStackCreationData(context, amplifyAppId, stackDescriptionData); diff --git a/packages/amplify-provider-awscloudformation/src/setup-new-user.js b/packages/amplify-provider-awscloudformation/src/setup-new-user.js index 3a55a972da9..210c1c62d57 100644 --- a/packages/amplify-provider-awscloudformation/src/setup-new-user.js +++ b/packages/amplify-provider-awscloudformation/src/setup-new-user.js @@ -9,7 +9,7 @@ const { open } = require('amplify-cli-core'); const isOnWsl = require('is-wsl'); async function run(context) { - const awsConfig = { + const awsConfigInfo = { accessKeyId: constants.DefaultAWSAccessKeyId, secretAccessKey: constants.DefaultAWSSecretAccessKey, region: constants.DefaultAWSRegion, @@ -30,10 +30,10 @@ async function run(context) { name: 'region', message: 'region: ', choices: awsRegions, - default: awsConfig.region, + default: awsConfigInfo.region, }, ]); - awsConfig.region = answers.region; + awsConfigInfo.region = answers.region; context.print.info('Specify the username of the new IAM user:'); const { userName } = await inquirer.prompt([ { @@ -44,7 +44,7 @@ async function run(context) { }, ]); - let deepLinkURL = constants.AWSCreateIAMUsersUrl.replace('{userName}', userName).replace('{region}', awsConfig.region); + let deepLinkURL = constants.AWSCreateIAMUsersUrl.replace('{userName}', userName).replace('{region}', awsConfigInfo.region); const isOnWindows = process.platform === 'win32'; if (isOnWindows || isOnWsl) { deepLinkURL = deepLinkURL.replace('$new', '`$new'); @@ -61,7 +61,7 @@ async function run(context) { mask: '*', name: 'accessKeyId', message: 'accessKeyId: ', - default: awsConfig.accessKeyId, + default: awsConfigInfo.accessKeyId, transformer: obfuscationUtil.transform, validate: input => { if (input === constants.DefaultAWSAccessKeyId || input.length < 16 || input.length > 128 || !/^[\w]+$/.test(input)) { @@ -83,7 +83,7 @@ async function run(context) { mask: '*', name: 'secretAccessKey', message: 'secretAccessKey: ', - default: awsConfig.secretAccessKey, + default: awsConfigInfo.secretAccessKey, transformer: obfuscationUtil.transform, validate: input => { if (input === constants.DefaultAWSSecretAccessKey || input.trim().length === 0) { @@ -95,13 +95,13 @@ async function run(context) { ]); if (accountDetails.accessKeyId) { - awsConfig.accessKeyId = accountDetails.accessKeyId.trim(); + awsConfigInfo.accessKeyId = accountDetails.accessKeyId.trim(); } if (accountDetails.secretAccessKey) { - awsConfig.secretAccessKey = accountDetails.secretAccessKey.trim(); + awsConfigInfo.secretAccessKey = accountDetails.secretAccessKey.trim(); } - if (validateAWSConfig(awsConfig)) { + if (validateAWSConfig(awsConfigInfo)) { let profileName = 'default'; context.print.warning('This would update/create the AWS Profile in your local machine'); const profileDetails = await inquirer.prompt([ @@ -115,7 +115,7 @@ async function run(context) { profileName = profileDetails.pn.trim(); - systemConfigManager.setProfile(awsConfig, profileName); + systemConfigManager.setProfile(awsConfigInfo, profileName); context.print.info(''); context.print.success('Successfully set up the new user.'); return profileName; @@ -125,8 +125,10 @@ async function run(context) { throw new Error('New user setup failed.'); } -function validateAWSConfig(awsConfig) { - return awsConfig.accessKeyId !== constants.DefaultAWSAccessKeyId && awsConfig.secretAccessKey !== constants.DefaultAWSSecretAccessKey; +function validateAWSConfig(awsConfigInfo) { + return ( + awsConfigInfo.accessKeyId !== constants.DefaultAWSAccessKeyId && awsConfigInfo.secretAccessKey !== constants.DefaultAWSSecretAccessKey + ); } module.exports = { diff --git a/packages/amplify-provider-awscloudformation/src/system-config-manager.ts b/packages/amplify-provider-awscloudformation/src/system-config-manager.ts index ec2b1d5c447..92188e63bc7 100644 --- a/packages/amplify-provider-awscloudformation/src/system-config-manager.ts +++ b/packages/amplify-provider-awscloudformation/src/system-config-manager.ts @@ -13,7 +13,7 @@ const logger = fileLogger('system-config-manager'); const credentialsFilePath = pathManager.getAWSCredentialsFilePath(); const configFilePath = pathManager.getAWSConfigFilePath(); -export function setProfile(awsConfig: $TSAny, profileName: string) { +export function setProfile(awsConfigInfo: $TSAny, profileName: string) { fs.ensureDirSync(pathManager.getDotAWSDirPath()); let credentials = {}; @@ -34,15 +34,15 @@ export function setProfile(awsConfig: $TSAny, profileName: string) { Object.keys(credentials).forEach(key => { const keyName = key.trim(); if (profileName === keyName) { - credentials[key].aws_access_key_id = awsConfig.accessKeyId; - credentials[key].aws_secret_access_key = awsConfig.secretAccessKey; + credentials[key].aws_access_key_id = awsConfigInfo.accessKeyId; + credentials[key].aws_secret_access_key = awsConfigInfo.secretAccessKey; isCredSet = true; } }); if (!isCredSet) { credentials[profileName] = { - aws_access_key_id: awsConfig.accessKeyId, - aws_secret_access_key: awsConfig.secretAccessKey, + aws_access_key_id: awsConfigInfo.accessKeyId, + aws_secret_access_key: awsConfigInfo.secretAccessKey, }; } @@ -50,14 +50,14 @@ export function setProfile(awsConfig: $TSAny, profileName: string) { Object.keys(config).forEach(key => { const keyName = key.replace('profile', '').trim(); if (profileName === keyName) { - config[key].region = awsConfig.region; + config[key].region = awsConfigInfo.region; isConfigSet = true; } }); if (!isConfigSet) { const keyName = profileName === 'default' ? 'default' : `profile ${profileName}`; config[keyName] = { - region: awsConfig.region, + region: awsConfigInfo.region, }; } logger('setProfile.writecredetialsFilePath', [credentialsFilePath])(); @@ -66,7 +66,7 @@ export function setProfile(awsConfig: $TSAny, profileName: string) { } export async function getProfiledAwsConfig(context: $TSContext, profileName: string, isRoleSourceProfile?: boolean) { - let awsConfig; + let awsConfigInfo; const httpProxy = process.env.HTTP_PROXY || process.env.HTTPS_PROXY; const profileConfig = getProfileConfig(profileName); if (profileConfig) { @@ -75,18 +75,18 @@ export async function getProfiledAwsConfig(context: $TSContext, profileName: str const roleCredentials = await getRoleCredentials(context, profileName, profileConfig); delete profileConfig.role_arn; delete profileConfig.source_profile; - awsConfig = { + awsConfigInfo = { ...profileConfig, ...roleCredentials, }; } else { logger('getProfiledAwsConfig.getProfileCredentials', [profileName]); const profileCredentials = getProfileCredentials(profileName); - awsConfig = { + awsConfigInfo = { ...profileConfig, ...profileCredentials, }; - validateCredentials(awsConfig, profileName); + validateCredentials(awsConfigInfo, profileName); } } else { const err = new Error(`Profile configuration is missing for: ${profileName}`); @@ -95,13 +95,13 @@ export async function getProfiledAwsConfig(context: $TSContext, profileName: str } if (httpProxy) { - awsConfig = { - ...awsConfig, + awsConfigInfo = { + ...awsConfigInfo, httpOptions: { agent: proxyAgent(httpProxy) }, }; } - return awsConfig; + return awsConfigInfo; } function makeFileOwnerReadWrite(filePath: string) { @@ -232,7 +232,8 @@ function isCredentialsExpired(roleCredentials: $TSAny) { } export async function resetCache(context: $TSContext, profileName: string) { - let awsConfig; + let awsConfigInfo; + const profileConfig = getProfileConfig(profileName); const cacheFilePath = getCacheFilePath(); if (profileConfig && profileConfig.role_arn && fs.existsSync(cacheFilePath)) { @@ -251,7 +252,8 @@ export async function resetCache(context: $TSContext, profileName: string) { context.print.info(' No temp credentials are cached for the project.'); context.print.info(''); } - return awsConfig; + + return awsConfigInfo; } function getCacheFilePath() { diff --git a/packages/amplify-provider-awscloudformation/src/utils/admin-helpers.ts b/packages/amplify-provider-awscloudformation/src/utils/admin-helpers.ts index b4482b963f6..1bbc2a42859 100644 --- a/packages/amplify-provider-awscloudformation/src/utils/admin-helpers.ts +++ b/packages/amplify-provider-awscloudformation/src/utils/admin-helpers.ts @@ -35,8 +35,10 @@ export async function getTempCredsWithAdminTokens(context: $TSContext, appId: st const authConfig = await getRefreshedTokens(context, appId); const { idToken, IdentityId, region } = authConfig; // use tokens to get creds and assign to config - const awsConfig = await getAdminCognitoCredentials(idToken, IdentityId, region); - aws.config.update(awsConfig); + const awsConfigInfo = await getAdminCognitoCredentials(idToken, IdentityId, region); + + aws.config.update(awsConfigInfo); + // need to use Cognito creds to get STS creds - otherwise // users will not be able to provision Cognito resources return await getAdminStsCredentials(idToken, region); diff --git a/packages/amplify-provider-awscloudformation/src/utils/auth-types.ts b/packages/amplify-provider-awscloudformation/src/utils/auth-types.ts index 500e31bd6e0..af2e9303e93 100644 --- a/packages/amplify-provider-awscloudformation/src/utils/auth-types.ts +++ b/packages/amplify-provider-awscloudformation/src/utils/auth-types.ts @@ -1,6 +1,6 @@ import { $TSAny } from 'amplify-cli-core'; -export type AuthFlow = 'admin' | 'profile' | 'accessKeys'; +export type AuthFlow = 'admin' | 'profile' | 'accessKeys' | 'general'; export interface AuthFlowConfig extends Partial { type: AuthFlow; appId?: string; diff --git a/packages/amplify-util-mock/src/utils/lambda/populate-lambda-mock-env-vars.ts b/packages/amplify-util-mock/src/utils/lambda/populate-lambda-mock-env-vars.ts index 3449c31f43b..dc4b06882be 100644 --- a/packages/amplify-util-mock/src/utils/lambda/populate-lambda-mock-env-vars.ts +++ b/packages/amplify-util-mock/src/utils/lambda/populate-lambda-mock-env-vars.ts @@ -28,11 +28,11 @@ const getAwsCredentials = async (_, context: $TSContext): Promise Date: Mon, 12 Jul 2021 14:59:20 -0400 Subject: [PATCH 016/125] chore: update yarn.lock file (#7644) Co-authored-by: Colin Ihrig --- yarn.lock | 101 +----------------------------------------------------- 1 file changed, 1 insertion(+), 100 deletions(-) diff --git a/yarn.lock b/yarn.lock index 09351b752d8..341a0d19fda 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9723,7 +9723,7 @@ camel-case@4.1.1, camel-case@^4.1.1: pascal-case "^3.1.1" tslib "^1.10.0" -camel-case@4.1.2, camel-case@^4.1.2: +camel-case@4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/camel-case/-/camel-case-4.1.2.tgz#9728072a954f805228225a6deea6b38461e1bd5a" integrity sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw== @@ -9824,15 +9824,6 @@ capital-case@^1.0.3: tslib "^1.10.0" upper-case-first "^2.0.1" -capital-case@^1.0.4: - version "1.0.4" - resolved "https://registry.npmjs.org/capital-case/-/capital-case-1.0.4.tgz#9d130292353c9249f6b00fa5852bee38a717e669" - integrity sha512-ds37W8CytHgwnhGGTi88pcPyR15qoNkOpYwmMMfnWqqWgESapLqvDx6huFjQ5vqWSn2Z06173XNA7LtMOeUh1A== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - upper-case-first "^2.0.2" - capture-exit@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/capture-exit/-/capture-exit-2.0.0.tgz#fb953bfaebeb781f62898239dabb426d08a509a4" @@ -9981,24 +9972,6 @@ change-case@^4.1.1: snake-case "^3.0.3" tslib "^1.10.0" -change-case@^4.1.2: - version "4.1.2" - resolved "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz#fedfc5f136045e2398c0410ee441f95704641e12" - integrity sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A== - dependencies: - camel-case "^4.1.2" - capital-case "^1.0.4" - constant-case "^3.0.4" - dot-case "^3.0.4" - header-case "^2.0.4" - no-case "^3.0.4" - param-case "^3.0.4" - pascal-case "^3.1.2" - path-case "^3.0.4" - sentence-case "^3.0.4" - snake-case "^3.0.4" - tslib "^2.0.3" - char-regex@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf" @@ -10654,15 +10627,6 @@ constant-case@^2.0.0: snake-case "^2.1.0" upper-case "^1.1.1" -constant-case@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/constant-case/-/constant-case-3.0.4.tgz#3b84a9aeaf4cf31ec45e6bf5de91bdfb0589faf1" - integrity sha512-I2hSBi7Vvs7BEuJDr5dDHfzb/Ruj3FyvFyh7KLilAjNQw3Be+xgqUBA2W6scVEcL0hL1dwPRtIqEPVUCKkSsyQ== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - upper-case "^2.0.2" - constants-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" @@ -12008,14 +11972,6 @@ dot-case@^3.0.3: no-case "^3.0.3" tslib "^1.10.0" -dot-case@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751" - integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - dot-prop@^4.2.0: version "4.2.1" resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" @@ -14606,14 +14562,6 @@ header-case@^2.0.3: capital-case "^1.0.3" tslib "^1.10.0" -header-case@^2.0.4: - version "2.0.4" - resolved "https://registry.npmjs.org/header-case/-/header-case-2.0.4.tgz#5a42e63b55177349cf405beb8d775acabb92c063" - integrity sha512-H/vuk5TEEVZwrR0lp2zed9OCo1uAILMlx0JEMgC26rzyJJ3N1v6XkwHHXJQdR2doSjcGPM6OKPYoJgf0plJ11Q== - dependencies: - capital-case "^1.0.4" - tslib "^2.0.3" - "heap@>= 0.2.0": version "0.2.6" resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac" @@ -19121,14 +19069,6 @@ param-case@^2.1.0: dependencies: no-case "^2.2.0" -param-case@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz#7d17fe4aa12bde34d4a77d91acfb6219caad01c5" - integrity sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - parent-module@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-1.0.1.tgz#691d2709e78c79fae3a156622452d00762caaaa2" @@ -19269,14 +19209,6 @@ path-case@^3.0.3: dot-case "^3.0.3" tslib "^1.10.0" -path-case@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/path-case/-/path-case-3.0.4.tgz#9168645334eb942658375c56f80b4c0cb5f82c6f" - integrity sha512-qO4qCFjXqVTrcbPt/hQfhTQ+VhFsqNKOPtytgNKkKxSoEp3XPUQ8ObFuePylOIok5gjn69ry8XiULxCwot3Wfg== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -21868,15 +21800,6 @@ sentence-case@^3.0.3: tslib "^1.10.0" upper-case-first "^2.0.1" -sentence-case@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/sentence-case/-/sentence-case-3.0.4.tgz#3645a7b8c117c787fde8702056225bb62a45131f" - integrity sha512-8LS0JInaQMCRoQ7YUytAo/xUu5W2XnQxV2HI/6uM6U7CITS1RqPElr30V6uIqyMKM9lJGRVFy5/4CuzcixNYSg== - dependencies: - no-case "^3.0.4" - tslib "^2.0.3" - upper-case-first "^2.0.2" - serialize-javascript@4.0.0, serialize-javascript@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-4.0.0.tgz#b525e1238489a5ecfc42afacc3fe99e666f4b1aa" @@ -22170,14 +22093,6 @@ snake-case@^3.0.3: dot-case "^3.0.3" tslib "^1.10.0" -snake-case@^3.0.4: - version "3.0.4" - resolved "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c" - integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg== - dependencies: - dot-case "^3.0.4" - tslib "^2.0.3" - snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -23813,13 +23728,6 @@ upper-case-first@^2.0.1: dependencies: tslib "^1.10.0" -upper-case-first@^2.0.2: - version "2.0.2" - resolved "https://registry.npmjs.org/upper-case-first/-/upper-case-first-2.0.2.tgz#992c3273f882abd19d1e02894cc147117f844324" - integrity sha512-514ppYHBaKwfJRK/pNC6c/OxfGa0obSnAl106u97Ed0I625Nin96KAjttZF6ZL3e1XLtphxnqrOi9iWgm+u+bg== - dependencies: - tslib "^2.0.3" - upper-case@2.0.1, upper-case@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-2.0.1.tgz#6214d05e235dc817822464ccbae85822b3d8665f" @@ -23832,13 +23740,6 @@ upper-case@^1.0.3, upper-case@^1.1.0, upper-case@^1.1.1, upper-case@^1.1.3: resolved "https://registry.yarnpkg.com/upper-case/-/upper-case-1.1.3.tgz#f6b4501c2ec4cdd26ba78be7222961de77621598" integrity sha1-9rRQHC7EzdJrp4vnIilh3ndiFZg= -upper-case@^2.0.2: - version "2.0.2" - resolved "https://registry.npmjs.org/upper-case/-/upper-case-2.0.2.tgz#d89810823faab1df1549b7d97a76f8662bae6f7a" - integrity sha512-KgdgDGJt2TpuwBUIjgG6lzw2GWFRCW9Qkfkiv0DxqHHLYJHmtmdUIKcZd8rHgFSjopVTlw6ggzCm1b8MFQwikg== - dependencies: - tslib "^2.0.3" - uri-js@^4.2.2: version "4.4.0" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.0.tgz#aa714261de793e8a82347a7bcc9ce74e86f28602" From 0e1db59cf5c3e9d7d6d9aff392c52e4e7ae74910 Mon Sep 17 00:00:00 2001 From: Josue Ruiz Date: Tue, 13 Jul 2021 17:54:10 -0700 Subject: [PATCH 017/125] test(amplify-console-integration-tests): update the add environment fn ref pr#7098 (#7719) --- .../src/consoleHosting/consoleHosting.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/amplify-console-integration-tests/src/consoleHosting/consoleHosting.ts b/packages/amplify-console-integration-tests/src/consoleHosting/consoleHosting.ts index f9d4e69d781..3459bd1b1c8 100644 --- a/packages/amplify-console-integration-tests/src/consoleHosting/consoleHosting.ts +++ b/packages/amplify-console-integration-tests/src/consoleHosting/consoleHosting.ts @@ -37,8 +37,6 @@ export function deleteProject(cwd: string, deleteDeploymentBucket: Boolean = tru export function addEnvironment(cwd: string, settings: any): Promise { return new Promise((resolve, reject) => { spawn(getCLIPath(), ['env', 'add', '--providers', JSON.stringify(settings.providersParam)], { cwd, stripColors: true }) - .wait('Do you want to use an existing environment?') - .sendLine('n') .wait('Enter a name for the environment') .sendLine(settings.envName) .wait('Try "amplify add api" to create a backend API and then "amplify publish" to deploy everything') From 3e2e6305b5a74db2a282dc33b0cc5d24f1c8eaaf Mon Sep 17 00:00:00 2001 From: John Hockett Date: Tue, 13 Jul 2021 17:55:33 -0700 Subject: [PATCH 018/125] fix: checkout into existing env with new LL (#7687) * fix: checkout into existing env with new LL --- .../provider-utils/awscloudformation/index.ts | 6 +++-- .../cfn-template-utils.test.ts | 2 +- .../awscloudformation/cfn-template-utils.ts | 8 ++----- packages/amplify-cli-core/src/cfnUtilities.ts | 23 ++++++++++++++++--- .../src/__tests__/layer.test.ts | 16 +++++++++---- 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/packages/amplify-category-function/src/provider-utils/awscloudformation/index.ts b/packages/amplify-category-function/src/provider-utils/awscloudformation/index.ts index bfc45aab53f..796ee0fee5f 100644 --- a/packages/amplify-category-function/src/provider-utils/awscloudformation/index.ts +++ b/packages/amplify-category-function/src/provider-utils/awscloudformation/index.ts @@ -405,8 +405,10 @@ export async function updateConfigOnEnvInit(context: $TSContext, resourceName: s } const currentCfnTemplatePath = pathManager.getCurrentCfnTemplatePath(projectPath, categoryName, resourceName); - const { cfnTemplate: currentCfnTemplate } = await readCFNTemplate(currentCfnTemplatePath); - await writeCFNTemplate(currentCfnTemplate, pathManager.getResourceCfnTemplatePath(projectPath, categoryName, resourceName)); + const { cfnTemplate: currentCfnTemplate } = (await readCFNTemplate(currentCfnTemplatePath, { throwIfNotExist: false })) || {}; + if (currentCfnTemplate !== undefined) { + await writeCFNTemplate(currentCfnTemplate, pathManager.getResourceCfnTemplatePath(projectPath, categoryName, resourceName)); + } } } } diff --git a/packages/amplify-category-storage/src/__tests__/provider-utils/awscloudformation/cfn-template-utils.test.ts b/packages/amplify-category-storage/src/__tests__/provider-utils/awscloudformation/cfn-template-utils.test.ts index 6c39960a109..60403b92a05 100644 --- a/packages/amplify-category-storage/src/__tests__/provider-utils/awscloudformation/cfn-template-utils.test.ts +++ b/packages/amplify-category-storage/src/__tests__/provider-utils/awscloudformation/cfn-template-utils.test.ts @@ -10,7 +10,7 @@ pathManager_mock.getBackendDirPath.mockReturnValue('/test/path'); describe('get existing table column names', () => { it('returns empty array when no template exists', async () => { - readCFNTemplate_mock.mockRejectedValueOnce('the template does not exist'); + readCFNTemplate_mock.mockResolvedValueOnce(undefined); const result = await getExistingTableColumnNames('testResource'); expect(result).toEqual([]); }); diff --git a/packages/amplify-category-storage/src/provider-utils/awscloudformation/cfn-template-utils.ts b/packages/amplify-category-storage/src/provider-utils/awscloudformation/cfn-template-utils.ts index 897baa68fce..0ba81f3368f 100644 --- a/packages/amplify-category-storage/src/provider-utils/awscloudformation/cfn-template-utils.ts +++ b/packages/amplify-category-storage/src/provider-utils/awscloudformation/cfn-template-utils.ts @@ -30,12 +30,8 @@ const loadCfnTemplateSafe = async (resourceName?: string): Promise