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
460 stars 116 forks source link

Amplifypush gives Error: Missing required dependencies to package #1368

Open simpian opened 3 years ago

simpian commented 3 years ago

Describe the bug Build works fine when i initialize the project, like no backend lambda functions, but as soon as add just one example lambda function, build starts failing. I'm able to do an amplify push on my local and backend can be deployed from local, but when i do a git push, and trigger the build, i get build failure, here is the log

this log is extracted from amplify console build log

To Reproduce my lambda functions are written in Java 11

                                 # Executing command: amplifyPush --simple
2020-12-12T19:06:51.858Z [INFO]: 
2020-12-12T19:06:51.860Z [INFO]: For more information on AWS Profiles, see:
                                 https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html
2020-12-12T19:06:52.171Z [INFO]: Amplify AppID found: dmby4dyvtonmc. Amplify App name is: xxx
2020-12-12T19:06:52.219Z [INFO]: Backend environment dev found in Amplify Console app: xxx
2020-12-12T19:06:52.966Z [WARNING]: - Fetching updates to backend environment: dev from the cloud.
2020-12-12T19:06:53.240Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud.
2020-12-12T19:06:53.273Z [INFO]: 
2020-12-12T19:06:55.243Z [INFO]: Note: It is recommended to run this command from the root of your app directory
2020-12-12T19:07:00.103Z [WARNING]: - Initializing your environment: dev
2020-12-12T19:07:00.386Z [WARNING]: ✔ Initialized provider successfully.
2020-12-12T19:07:00.561Z [INFO]: Unable to find Java version >=11 on the path. Download link: https://amzn.to/2UUljp9
                                 Unable to find Java compiler version >=11 on the path. Download link: https://amzn.to/2UUljp9
                                 Unable to find Gradle version >=5 on the path. Download link: https://bit.ly/3aGYDj6
2020-12-12T19:07:00.562Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud
2020-12-12T19:07:00.562Z [WARNING]: ✖ There was an error initializing your environment.
2020-12-12T19:07:00.564Z [INFO]: init failed
2020-12-12T19:07:00.565Z [INFO]: Error: Missing required dependencies to package User
                                     at Object.buildResource (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/build-resources.js:30:11)
                                     at processTicksAndRejections (internal/process/task_queues.js:97:5)
                                     at packageResource (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:483:16)
                                     at async Promise.all (index 0)
                                     at Object.run (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:102:5)
2020-12-12T19:07:00.581Z [ERROR]: !!! Build failed
2020-12-12T19:07:00.582Z [ERROR]: !!! Non-Zero Exit Code detected
2020-12-12T19:07:00.582Z [INFO]: # Starting environment caching...
2020-12-12T19:07:00.582Z [INFO]: # Environment caching completed

Expected behavior amplify should build with no errors

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

garyleefight commented 3 years ago

Can you provide your appId and region? What is the amplify cli version you used in AWS Amplify Console?

simpian commented 3 years ago

Can you provide your appId and region? What is the amplify cli version you used in AWS Amplify Console?

appid: dmby4dyvtonmc region: us-east-1

Athena96 commented 3 years ago

Hi @simpian Java is currently not supported in Amplify's default build image. I have created a backlog item for this, and we'll update here once this is added. In the meantime, as a workaround you can:

si3mshady commented 3 years ago

Happening to me also. Started after I added 1 API and 1 lambda function to a simple application I am working on. Like @simpian indicated

si3mshady commented 3 years ago

021-02-09T02:07:00.265Z [INFO]: 2021-02-09T02:07:00.268Z [INFO]: For more information on AWS Profiles, see: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html 2021-02-09T02:07:00.753Z [INFO]: Amplify AppID found: d3u1arczmsatez. Amplify App name is: strayaway 2021-02-09T02:07:00.802Z [INFO]: Backend environment dev found in Amplify Console app: strayaway 2021-02-09T02:07:01.565Z [WARNING]: - Fetching updates to backend environment: dev from the cloud. 2021-02-09T02:07:01.910Z [WARNING]: ✔ Successfully pulled backend environment dev from the cloud. 2021-02-09T02:07:01.944Z [INFO]: 2021-02-09T02:07:04.174Z [INFO]: Note: It is recommended to run this command from the root of your app directory 2021-02-09T02:07:09.564Z [WARNING]: - Initializing your environment: dev 2021-02-09T02:07:09.890Z [WARNING]: ✔ Initialized provider successfully. 2021-02-09T02:07:10.400Z [INFO]: python3 found but version Python 3.7.9 is less than the minimum required version. You must have python >= 3.8 installed and available on your PATH as "python3" or "python". It can be installed from https://www.python.org/downloads You must have pipenv installed and available on your PATH as "pipenv". It can be installed by running "pip3 install --user pipenv". 2021-02-09T02:07:10.400Z [WARNING]: ✖ An error occurred when pushing the resources to the cloud 2021-02-09T02:07:10.400Z [WARNING]: ✖ There was an error initializing your environment. 2021-02-09T02:07:10.403Z [INFO]: init failed 2021-02-09T02:07:10.405Z [INFO]: Error: Missing required dependencies to package strayawayfunc  at Object.buildResource (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/build-resources.js:30:11)  at processTicksAndRejections (internal/process/task_queues.js:97:5)  at packageResource (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:489:14)  at async Promise.all (index 0)  at Object.run (/root/.nvm/versions/node/v12.19.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-provider-awscloudformation/src/push-resources.ts:113:5) 2021-02-09T02:07:10.423Z [ERROR]: !!! Build failed 2021-02-09T02:07:10.424Z [ERROR]: !!! Non-Zero Exit Code detected 2021-02-09T02:07:10.424Z [INFO]: # Starting environment caching... 2021-02-09T02:07:10.424Z [INFO]: # Environment caching completed Terminating logging...

Raees678 commented 3 years ago

Hi, I'm facing a similar issue when using Python lambdas in my project. Is there any solution for this yet? Originally I was getting the same error as @si3mshady. So I added some lines to the build script to install Python 3.8 in the container before running amplifyPush:

    - export BASE_PATH=$(pwd)
    - yum install -y gcc openssl-devel bzip2-devel libffi-devel python3.8-pip > /dev/null
    - cd /opt && wget -q https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz > /dev/null
    - cd /opt && tar xzf Python-3.8.2.tgz > /dev/null
    - cd /opt/Python-3.8.2 && ./configure --enable-optimizations > /dev/null
    - cd /opt/Python-3.8.2 && make altinstall > /dev/null
    - pip3.8 install --user pipenv > /dev/null
    - ln -fs /usr/local/bin/python3.8 /usr/bin/python3 >/dev/null
    - ln -fs /usr/local/bin/pip3.8 /usr/bin/pip3 > /dev/null
    - cd $BASE_PATH

to the yml build specification. However, now it successfully installs python 3.8 but still errors out while pushing.

The error message looks like this:

                                Creating a virtualenv for this project...
                                Pipfile: /codebuild/output/src934188498/src/personal-frontend/amplify/backend/function/createAnInterviewLambda/Pipfile
                                Using /usr/local/bin/python3.8 (3.8.2) to create virtualenv...
                                ⠋ Creating virtual environment...
⠙ Creating virtual environment...
⠹ Creating virtual environment...
⠸ Creating virtual environment...
⠼ Creating virtual environment...
⠴ Creating virtual environment...
⠦ Creating virtual environment...
⠧ Creating virtual environment...
⠇ Creating virtual environment...
⠏ Creating virtual environment...
⠋ Creating virtual environment...
⠙ Creating virtual environment...
⠹ Creating virtual environment...
⠸ Creating virtual environment...
⠼ Creating virtual environment...
⠴ Creating virtual environment...
⠦ Creating virtual environment...
⠧ Creating virtual environment...
⠇ Creating virtual environment...
⠏ Creating virtual environment...
⠋ Creating virtual environment...
⠙ Creating virtual environment...
⠹ Creating virtual environment...
⠸ Creating virtual environment...
⠼ Creating virtual environment...
⠴ Creating virtual environment...
⠦ Creating virtual environment...
⠧ Creating virtual environment...
⠇ Creating virtual environment...created virtual environment CPython3.8.2.final.0-64 in 1230ms
                                creator CPython3Posix(dest=/root/.local/share/virtualenvs/createAnInterviewLambda-l_7Y9xC-, clear=False, no_vcs_ignore=False, global=False)
                                seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/root/.local/share/virtualenv)
                                added seed packages: pip==21.0.1, setuptools==52.0.0, wheel==0.36.2
                                activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
                                ✔ Successfully created virtual environment!
                                Virtualenv location: /root/.local/share/virtualenvs/createAnInterviewLambda-l_7Y9xC-
                                Installing dependencies from Pipfile.lock (98dbad)...] running command [pipenv install]
                                at Object.execAsStringPromise (/root/.nvm/versions/node/v12.21.0/lib/node_modules/@aws-amplify/cli/node_modules/amplify-python-function-runtime-provider/src/util/pyUtils.ts:43:11)
                                at runMicrotasks (<anonymous>)
                                at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-03-13T07:15:47.208Z [ERROR]: !!! Build failed

It seems to fail while installing dependencies from Pipfile.lock.

The only time it seems to work is when I override the Amplify CLI version to version 4.2 in Build Settings > Live Package Updates. However I would prefer if I didn't use such an outdated version of the CLI.

kondo-to commented 3 years ago

create a custom build image: https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-image.html

Thank you for your advise !

I made some docker image for java11 corretto and gradle 6.4.1 to build it via Amplify Console. and finally It works well in my region (ap-northeast-1) To save time (for someone), I put link on here

https://gallery.ecr.aws/v5a0p7x7/amplify-build-java11-gradle

tmli3b3rm4n commented 1 year ago

Is Go supported?