amplify-cli icon indicating copy to clipboard operation
amplify-cli copied to clipboard

Amplify version cli 11 breaks cicd with `No package manager found.`

Open austinamorusoyardstick opened this issue 3 years ago • 24 comments

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

16.0.0

Amplify CLI Version

11.0.0

What operating system are you using?

Mac

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

Running the amplify CI/CD in the amplify console with amplify cli version 11 breaks the CI/CD

                                    - Building custom resources
2023-03-13T22:54:14.709Z [WARNING]: ✖ There was an error initializing your environment.
2023-03-13T22:54:14.710Z [INFO]: 🛑 No package manager found.
                                 Resolution: Install npm or yarn to compile overrides for this project.
                                 Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
2023-03-13T22:54:14.728Z [INFO]: 
2023-03-13T22:54:14.728Z [INFO]: Session Identifier: 1d05c407-17d0-479f-9c09-aa6c69927f19
2023-03-13T22:54:14.753Z [ERROR]: !!! Build failed
2023-03-13T22:54:14.753Z [ERROR]: !!! Non-Zero Exit Code detected
2023-03-13T22:54:14.753Z [INFO]: # Starting environment caching...
2023-03-13T22:54:14.753Z [INFO]: # Environment caching completed
Terminating logging...

Expected behavior

I expect the CI/CD pipeline to work. K thanks bye

Reproduction steps

  1. Run a new build with amplify CLI version 11
  2. Watch the build run till the backend build hits the error
  3. Thanks

Project Identifier

No response

Log output

dsaf

Additional information

fsda

Before submitting, please confirm:

  • [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • [X] I have removed any sensitive information from my code snippets and submission.

austinamorusoyardstick avatar Mar 13 '23 23:03 austinamorusoyardstick

We also had this issue, rolling back to 10.8.1 fixed it. The logs were unhelpful.

cunneen avatar Mar 14 '23 03:03 cunneen

We got a similar issue during CI/CD on our custom auth resource which i suppose has to do with dependency updates on 11.0.0. Reverting back to 10.8.1 works with no problems

2023-03-14T10:19:23.019Z [WARNING]: ✖ There was an error initializing your environment.
2023-03-14T10:19:23.714Z [INFO]: 🛑 Packaging overrides failed.
                                 Command failed with exit code 2: /codebuild/output/src642526286/src/project/amplify/backend/node_modules/.bin/tsc --project /codebuild/output/src642526286/src/project/amplify/backend/auth/projectf6b2c276/build/tsconfig.resource.json
                                 ../override.ts(2,26): error TS2307: Cannot find module '@aws-cdk/aws-cognito' or its corresponding type declarations.
                                 ../override.ts(3,22): error TS2307: Cannot find module '@aws-cdk/core' or its corresponding type declarations.
                                 Resolution: There may be errors in your overrides file. If so, fix the errors and try again.
2023-03-14T10:19:23.715Z [INFO]: Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/

maismail avatar Mar 14 '23 11:03 maismail

related to https://github.com/aws-amplify/docs/pull/4990

ykethan avatar Mar 14 '23 14:03 ykethan

Hey, With the release of Amplify CLI version v11, AWS CDK v2 has been released. If your Amplify project utilizes overrides or custom resources created on a prior version of the Amplify CLI the resources will need to be migrated to the new version.

  1. For Amplify projects using overrides: Upgrade @aws-amplify/cli-extensibility-helper to version ^3.0.0
  2. For Amplify projects using custom: Update package.json for custom categories and update cdk-stack.ts for custom categories as follows. ts-guide-cdk ts-guide-cdk-package

To know more about the CDK Migration procedure, refer to migrating to v2

ykethan avatar Mar 14 '23 15:03 ykethan

I'm not getting error anymore when I do amplify push in terminal, but I'm still getting error like so in AWS Amplify CD build:

2023-03-14T16:59:48.114Z [INFO]: 🛑 The following resources failed to deploy:
                                 Resource Name: apiEssGraphQLAPI (AWS::CloudFormation::Stack)
                                 Event Type: update
                                 Reason: Parameters: [CreateAPIKey] do not exist in the template
                                 URL: https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/arn%3Aaws%3Acloudformation%3Aus-east-1%3A914282159778%3Astack%2F...redacted...c40-492c-11ea-b93a-0a9564c9a859/events
2023-03-14T16:59:48.125Z [WARNING]: ✖ There was an error initializing your environment.
2023-03-14T16:59:48.126Z [INFO]: 🛑 Resource is not in the state stackUpdateComplete
2023-03-14T16:59:48.127Z [INFO]: Name: apiEssGraphQLAPI (AWS::CloudFormation::Stack), Event Type: update, Reason: Parameters: [CreateAPIKey] do not exist in the template
                                 Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
2023-03-14T16:59:48.141Z [INFO]: 
2023-03-14T16:59:48.141Z [INFO]: Session Identifier: 8a4bfa77-068e-4b84-ae5b-8c6c7710e183
2023-03-14T16:59:48.163Z [ERROR]: !!! Build failed
2023-03-14T16:59:48.163Z [ERROR]: !!! Non-Zero Exit Code detected

hisham avatar Mar 14 '23 17:03 hisham

Hey @hisham, was the Create API key manually added to the parameters.json before? https://docs.amplify.aws/cli-legacy/graphql-transformer/config-params/#createapikey

could you provide provide a some information on how the application and overrides are currently configured that would enable me in reproducing the issue.

ykethan avatar Mar 14 '23 18:03 ykethan

Hi @ykethan - I don't use API keys in my api and have not done anything related to CreateAPIKey from what I recall. BTW, reverting aws amplify in the CI to 10.8.1 resolved the issue for me.

The override.ts for our GraphQL API is as follows:

import { AmplifyApiGraphQlResourceStackTemplate } from '@aws-amplify/cli-extensibility-helper';

export function override(resources: AmplifyApiGraphQlResourceStackTemplate) {
  resources.opensearch.OpenSearchStreamingLambdaFunction.timeout = 30;
}

I'll send rest of our override.ts files to [email protected].

hisham avatar Mar 14 '23 18:03 hisham

I'm now doing a push locally and getting this error:

🛑 construct does not have an associated node. All constructs must extend the "Construct" base class

I didn't change anything in my override.ts. All I do was do an amplify env checkout for one of my dev environments then attempted to do an amplify push.

I reverted to v10 and the error went away.

hisham avatar Mar 15 '23 21:03 hisham

Hey @austinamorusoyardstick, I was able to produce the issue. Are you currently utilizing cloudformation templates as the custom resource mechanism? if yes, we have identified the root cause and the Amplify team is currently working on a fix. The current workaround would be to downgrade the Amplify CLI version to 10.8.1 until the fix rolls out. apologies on the inconvenience cause by this. marking this issue as bug.

@cunneen @maismail were you able to mitigate the issue by modifying the package.json as provided in the comment https://github.com/aws-amplify/amplify-cli/issues/12221#issuecomment-1468333793. if this does not mitigate the issue could you open a new issue as this would assist us in tracking the behaviours.

@hisham I am working on a reproduction, thank you for providing me the files. Could you open a new Github issue as the would help us in tracking this behaviour.

ykethan avatar Mar 15 '23 22:03 ykethan

We still stuck on version 1 of the templates and do use cloudformation. I'm not exactly sure what you mean by custom resource mechanism?

austinamorusoyardstick avatar Mar 15 '23 22:03 austinamorusoyardstick

hey @austinamorusoyardstick, apologies if I was not clear on the comment. custom resources mechanism meaning the templates added using amplify add custom where we are provided the option to select CDK or CloudFormation.

ykethan avatar Mar 15 '23 22:03 ykethan

Oh geez we've been using the cli for so long I can't remember locally we still have to use version 7.6.19 due to https://github.com/aws-amplify/amplify-category-api/issues/112 I'm gonna guess we do have a cloudformation override given I have a amplify/backend/awscloudformation folder and that when we started this project we didn't even have the option for cdk, as far as I can tell. Or perhaps this path is a bit more helpful? amplify/backend/ext/administration/administration-template.yml

austinamorusoyardstick avatar Mar 15 '23 23:03 austinamorusoyardstick

Also we haven't been able to move to v2 of the transform due to this issue as well. https://github.com/aws-amplify/amplify-category-api/issues/1314

austinamorusoyardstick avatar Mar 15 '23 23:03 austinamorusoyardstick

hey @austinamorusoyardstick, do you see a folder called custom in the amplify/backend folder?

ykethan avatar Mar 16 '23 02:03 ykethan

I am also seeing this issue. I have 3 custom cdk stacks. I am also attempting to use aws-cdk-lib 2.6 in order to get latest appsync features like this:

  "dependencies": {
    "@aws-amplify/cli-extensibility-helper": "^3.0.0",
    "aws-cdk-lib": "^2.69.0"
  },
  "resolutions": {
    "aws-cdk-lib": "^2.69.0"
  }

I will try to revert to aws-cdk-lib version 2.44 but I seem to doubt it will make a difference.

oste avatar Mar 16 '23 04:03 oste

hey @oste, the cli-extensibility-helper uses the CDK version i.e: 2.53.0. The package.json will need to have the same version of aws-cdk-lib. The upgrade to CDK version 2.68.0 will be will be rolling out in our upcoming releases. Please refer to the comment on https://github.com/aws-amplify/amplify-cli/issues/12224#issuecomment-1470818759

ykethan avatar Mar 16 '23 16:03 ykethan

@ykethan I did revert back to 2.53 and still get the same issue. This are my dependencies now

"dependencies": { "@aws-amplify/cli-extensibility-helper": "^3.0.0", "aws-cdk-lib": "~2.53.0", "constructs": "^10.1.279" },

oste avatar Mar 16 '23 16:03 oste

Hey @oste, apologies for inconvenience caused by this. noticed that the constructs has a different version. AWS CDK constructs also effects how the application behaves.

I currently, have the following dependencies which work as expected.

"dependencies": {
    "@aws-amplify/cli-extensibility-helper": "^3.0.0",
    "aws-cdk-lib": "~2.53.0",
    "constructs": "^10.0.5"
  },

additionally, could you add the --debug flag to the amplify push and provide us a screenshot/messages observed.

ykethan avatar Mar 16 '23 17:03 ykethan

change the constructs didn't help but that --debug output seems useful:

MissingOverridesInstallationRequirementsError: No package manager found.
    at new AmplifyNodePkgDetector (/snapshot/repo/build/node_modules/amplify-cli-core/lib/amplify-node-pkg-detector/amplify-nodejs-detector.js:73:19)
    at /snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/print-cdk-migration-warning.js:116:34
    at Array.forEach (<anonymous>)
    at getCustomResourcesWarning (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/print-cdk-migration-warning.js:111:27)
    at getMigrationMessage (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/print-cdk-migration-warning.js:133:39)
    at printCdkMigrationWarning (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/print-cdk-migration-warning.js:74:59)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/push-resources.js:236:5)
    at async Promise.all (index 0)
    at async providersPush (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:159:5)
    at async AmplifyToolkit.pushResources (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/push-resources.js:134:13)
    at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:189:9)
    at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:135:5)
    at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:33:9)
    at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:117:5)

oste avatar Mar 16 '23 17:03 oste

Hey @oste, thank you for the information and your patience on this issue. Wanted to get a little bit of information.

  1. Does any of your custom resources present in the custom folder utilize Cloudformation template as its type instead of CDK?
  2. Could you provide us your project identifier by running amplify diagnose --send-report and the amplify-meta.json?

ykethan avatar Mar 16 '23 18:03 ykethan