aws-amplify / amplify-hosting

AWS Amplify Hosting provides a Git-based workflow for deploying and hosting fullstack serverless web applications.
https://aws.amazon.com/amplify/hosting/
Apache License 2.0
450 stars 113 forks source link

CI/CD build failed on new Hosted web app #3478

Open zachegnermh opened 1 year ago

zachegnermh commented 1 year ago

Before opening, please confirm:

JavaScript Framework

Vue

Amplify APIs

Authentication, GraphQL API

Amplify Categories

auth, api, hosting

Environment information

``` # Put output below this line System: OS: Windows 10 10.0.19044 CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz Memory: 14.46 GB / 31.77 GB Binaries: Node: 16.16.0 - C:\Program Files\nodejs\node.EXE npm: 9.6.2 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 113.0.5672.92 Edge: Spartan (44.19041.1266.0), Chromium (113.0.1774.35) Internet Explorer: 11.0.19041.1566 npmPackages: @vue-responsive-dash/chartjs: ^0.1.4 => 0.1.4 @vue/cli-plugin-eslint: ~4.5.0 => 4.5.19 @vue/cli-plugin-router: ~4.5.0 => 4.5.19 @vue/cli-plugin-vuex: ~4.5.0 => 4.5.19 @vue/cli-service: ~4.5.0 => 4.5.19 @vue/compiler-sfc: 2.7.14 @vue/eslint-config-prettier: ^6.0.0 => 6.0.0 aws-amplify: ^5.2.0 => 5.2.0 axios: ^0.21.1 => 0.21.4 (0.26.0) chart.js: ^2.9.4 => 2.9.4 chartjs-plugin-datalabels: ^1.0.0 => 1.0.0 collect.js: ^4.34.3 => 4.36.1 data-table-vue: ^2.0.11 => 2.0.15 dev: 1.0.0 element-ui: ^2.15.12 => 2.15.13 eslint: ^6.8.0 => 6.8.0 eslint-plugin-prettier: ^3.3.1 => 3.4.1 eslint-plugin-vue: ^6.2.2 => 6.2.2 moment: ^2.29.4 => 2.29.4 prettier: ^2.2.1 => 2.8.8 sass: ~1.32.0 => 1.32.13 sass-loader: ^10.0.0 => 10.4.1 vue: ^2.6.11 => 2.7.14 vue-chartjs: ^3.5.1 => 3.5.1 vue-cli-plugin-vuetify: ~2.4.1 => 2.4.8 vue-excel-editor: ^1.5.19 => 1.5.19 vue-fullscreen: ^2.6.1 => 2.6.1 vue-responsive-dash: ^0.5.0 => 0.5.0 vue-router: ^3.2.0 => 3.6.5 vue-speedometer: ^1.8.0 => 1.8.0 vue-template-compiler: ^2.6.11 => 2.7.14 vue-xlsx: ^0.2.1 => 0.2.1 vue2-quill-editor: ^2.0.26 => 2.0.26 vuedraggable: ^2.24.3 => 2.24.3 vuetify: ^2.4.0 => 2.6.15 vuetify-loader: ^1.7.0 => 1.9.2 vuex: ^3.4.0 => 3.6.2 npmGlobalPackages: @aws-amplify/cli: 10.2.0 @vue/cli: 5.0.8 npm: 9.6.2 ```

Describe the bug

When connecting a CodeCommit repository to Amplify using built-in CI/CD, there is a bug that causes the app to fail on 'Backend Build' during deployment. The error message that is displayed states that the environment is missing values for 'appId' and 'type'.

Expected behavior

The app should deploy after connecting to a branch.

Reproduction steps

1.) Create a new CodeCommit repository in AWS. 2.) Create a new Amplify app in the Amplify console, connect the CodeCommit repository to the Amplify app using the built-in CI/CD feature. 3.) Use default build settings. 4.) App should starting deploying. 5.) Observe that the deployment fails with the error message "This environment is missing some parameter values. [appId,type] do not have values."

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line 2023-05-10T19:36:14.703Z [INFO]: ## Starting Backend Build # Starting phase: build 2023-05-10T19:36:16.688Z [INFO]: 🛑 This environment is missing some parameter values. [appId,type] do not have values. 2023-05-10T19:36:16.689Z [INFO]: Resolution: Run 'amplify push' interactively to specify values. Alternatively, manually add values in SSM ParameterStore for the following parameter names: /amplify/d33kgav0kn9955/main/AMPLIFY_hosting_amplifyhosting_appId /amplify/d33kgav0kn9955/main/AMPLIFY_hosting_amplifyhosting_type Learn more at: https://docs.amplify.aws/cli/reference/ssm-parameter-store/#manually-creating-parameters 2023-05-10T19:36:16.696Z [INFO]: 2023-05-10T19:36:16.696Z [INFO]: Session Identifier: 2e59d688-3983-4516-bea9-874cdde2766c 2023-05-10T19:36:16.696Z [WARNING]: - Creating Zip 2023-05-10T19:36:16.719Z [INFO]: 2023-05-10T19:36:16.719Z [INFO]: ✅ Report saved: /tmp/mrms/report-1683747376700.zip 2023-05-10T19:36:16.719Z [WARNING]: - Sending zip 2023-05-10T19:36:16.719Z [INFO]: File at path: '/codebuild/output/src663805636/src/mRMS-beta/amplify/backend/amplify-meta.json' does not exist 2023-05-10T19:36:16.721Z [WARNING]: ✖ Sending zip 2023-05-10T19:36:16.737Z [ERROR]: !!! Build failed 2023-05-10T19:36:16.737Z [ERROR]: !!! Non-Zero Exit Code detected 2023-05-10T19:36:16.737Z [INFO]: # Starting environment caching... 2023-05-10T19:36:16.738Z [INFO]: # Environment caching completed Terminating logging... ```

aws-exports.js

/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.

const awsmobile = {
    "aws_project_region": "us-east-1",
    "aws_appsync_graphqlEndpoint": "https://2ljeiv6uvnddpfkkh4koisclym.appsync-api.us-east-1.amazonaws.com/graphql",
    "aws_appsync_region": "us-east-1",
    "aws_appsync_authenticationType": "API_KEY",
    "aws_appsync_apiKey": "da2-rec6dczf7jdclaslnongrdvldi",
    "aws_cognito_identity_pool_id": "us-east-1:7be81c1f-475f-4327-aacf-26f9705e399b",
    "aws_cognito_region": "us-east-1",
    "aws_user_pools_id": "us-east-1_uu3Tjc2Vg",
    "aws_user_pools_web_client_id": "32otfepd1qnbgs2965a9eeere2",
    "oauth": {},
    "aws_cognito_username_attributes": [
        "EMAIL"
    ],
    "aws_cognito_social_providers": [],
    "aws_cognito_signup_attributes": [
        "EMAIL"
    ],
    "aws_cognito_mfa_configuration": "OFF",
    "aws_cognito_mfa_types": [
        "SMS"
    ],
    "aws_cognito_password_protection_settings": {
        "passwordPolicyMinLength": 8,
        "passwordPolicyCharacters": []
    },
    "aws_cognito_verification_mechanisms": [
        "EMAIL"
    ]
};

export default awsmobile;

Manual configuration

No response

Additional configuration

No response

Mobile Device

No response

Mobile Operating System

No response

Mobile Browser

No response

Mobile Browser Version

No response

Additional information and screenshots

No response

zachegnermh commented 1 year ago

Now also getting this error. 🛑 File at path: '/codebuild/output/src237460651/src/AppName/amplify/backend/backend-config.json' does not exist

Session Identifier: a17a314c-e48e-4bf1-92ee-ff517eb9978b

nadetastic commented 1 year ago

Hi @zachegnermh thank you for opening this issue. Could you share your APP ID please?

zachegnermh commented 1 year ago

Hi @nadetastic, here is the App ID d33kgav0kn9955

Austinb commented 1 year ago

We are having this same issue on a newly created app which is pulling down and building automatically. Using the PR referenced above (#3482) we were able to add the items to the Parameter Store as required.

The builds are still failing saying it can not pull the information from the Parameter Store. App ID is d158aszzmmth1v and amplify version is 12.0.3 which is the latest as of this comment.

As an aside it seems that amplify push will add these missing keys/values in automatically.

Screenshot 2023-06-01 215026

Austinb commented 1 year ago

To circle back on this it appears that the new app was created with the wrong Service Role. I noticed during the cloning process in build the SSM part was failing. After a bit of checking the app was using the role amplifyconsole-backend-role instead of the correct one which is AmplifyConsoleServiceRole-AmplifyRole under App settings. Once the app's role was updated and rebuilt manually it completed as expected and pulled down the settings from the Parameter Store.

So if you are coming here having a similar issue check the "Cloning repository" section of the build panel and see if you have a line like [WARNING] !Failed to set up process.env.secrets. If so check your Application's Service Role.