aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
186 stars 64 forks source link

Getting error "Unknown command: config" #2056

Open tech-meppem opened 2 months ago

tech-meppem commented 2 months ago

Environment information

System:
  OS: Windows 10 10.0.19045
  CPU: (12) x64 AMD Ryzen 5 5500
  Memory: 11.39 GB / 31.80 GB
Binaries:
  Node: 18.20.4 - ~\AppData\Local\nvs\default\node.EXE
  Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
  npm: 8.19.2 - ~\Documents\path\to\repo\node_modules\.bin\npm.CMD     
  pnpm: undefined - undefined
NPM Packages:
  @aws-amplify/auth-construct: 1.3.1
  @aws-amplify/backend: 1.3.0
  @aws-amplify/backend-auth: 1.2.0
  @aws-amplify/backend-cli: 1.2.8
  @aws-amplify/backend-data: 1.1.4
  @aws-amplify/backend-deployer: 1.1.4
  @aws-amplify/backend-function: 1.5.0
  @aws-amplify/backend-output-schemas: 1.2.0
  @aws-amplify/backend-output-storage: 1.1.2
  @aws-amplify/backend-secret: 1.1.3
  @aws-amplify/backend-storage: 1.2.0
  @aws-amplify/cli-core: 1.1.3
  @aws-amplify/client-config: 1.3.2
  @aws-amplify/deployed-backend-client: 1.4.1
  @aws-amplify/form-generator: 1.0.3
  @aws-amplify/model-generator: 1.0.8
  @aws-amplify/platform-core: 1.1.0
  @aws-amplify/plugin-types: 1.3.0
  @aws-amplify/sandbox: 1.2.2
  @aws-amplify/schema-generator: 1.2.4
  aws-amplify: 6.6.2
  aws-cdk: 2.159.1
  aws-cdk-lib: 2.159.1
  typescript: 5.5.2
AWS environment variables:
  AWS_NODEJS_CONNECTION_REUSE_ENABLED = 1
  AWS_SDK_LOAD_CONFIG = 1
  AWS_STS_REGIONAL_ENDPOINTS = regional
No CDK environment variables

Describe the bug

I'm trying to deploy to an amplify app using S3 buckets, not a repo (we're just doing feasibility / investigation POC). So everything has been zipped, and uploaded to S3, then selecting S3 bucket, then that zip when deploying updates.

We are zipping up the build outputs only, not the full repo. The site loads fine, but now it comes to implementing backend. But I cannot find much documentation or help for setting up the "backend" with manual deployment, as all examples use git repos with the "app settings" page.

The only thing I can find is this page: https://eu-north-1.console.aws.amazon.com/amplify/apps/<appid>/branches/staging/backend-help Which tells me to run a npx ampx generate config command.

However, when running that command, the help text of the command is printed, followed by "Error: Unknown command: config". config is not listed as an available command for ampx generate, so I am wondering if there is a recent update has changed things. It's not listed here either: https://docs.amplify.aws/react/reference/cli-commands/#npx-ampx-generate I cannot find anyone else facing this problem elsewhere. I have been searching extensively.

Reproduction steps

This is the command I'm running (with \ replaced), with the output:

npx amplify generate config --app-id <appid> --branch staging

ampx generate

Generates post deployment artifacts

Commands:
  ampx generate outputs               Generates Amplify backend outputs
  ampx generate forms                 Generates UI forms
  ampx generate graphql-client-code   Generates graphql API code
  ampx generate schema-from-database  Generates typescript data schema from a SQ
                                      L database

Options:
  --debug    Print debug logs to the console          [boolean] [default: false]
  --help     Show help                                                 [boolean]
  --profile  An AWS profile name.                                       [string]

Error: Unknown command: config
ykethan commented 2 months ago

Hey @tech-meppem, thank you for reaching out and reporting this. The amplify_outputs.json file can be generated using ampx generate outputs.

Example: https://docs.amplify.aws/react/deploy-and-host/fullstack-branching/branch-deployments/#generate-client-config

Marking this as bug to update the command.

abarke commented 2 months ago

I'm facing the same issue as support for GitLab Enterprise Edition is not available. When I run the following command as mentioned in the docs I get:

npx ampx generate outputs --app-id myAppId --branch staging

StackDoesNotExistError: Stack does not exist.
Resolution: Ensure the CloudFormation stack ID or Amplify App ID and branch specified are correct and exists, then re-run this command.

😕

Please support GitLab EE 🙏

tech-meppem commented 2 months ago

I'm facing the same issue as support for GitLab Enterprise Edition is not available. When I run the following command as mentioned in the docs I get:

npx ampx generate outputs --app-id myAppId --branch staging

StackDoesNotExistError: Stack does not exist.
Resolution: Ensure the CloudFormation stack ID or Amplify App ID and branch specified are correct and exists, then re-run this command.

😕

Please support GitLab EE 🙏

I'm also getting this issue. I currently believe it's likely due to region issues, as the app is on a different region to our IAM Identify Centre. However, that's just my best guess at the moment, and I'm currently investigating.

ykethan commented 2 months ago

Hey @abarke @tech-meppem , does this app have a Gen 2 backend thats being hosted on a different app or is this just a frontend only app?

tech-meppem commented 2 months ago

Hey @abarke @tech-meppem , does this app have a Gen 2 backend that's being hosted on a different app or is this just a frontend only app?

For me, no other hosted app at the moment. I'm trying to make a Gen 2 backend work on the same app (I guess?), although, it's being very unsuccessful.

abarke commented 2 months ago

Hey @abarke @tech-meppem , does this app have a Gen 2 backend thats being hosted on a different app or is this just a frontend only app?

Hey! I setup a new app in Gen 2 and chose the manual deployment. I zipped and uploaded my Nuxt .output folder and the app hosting is working (without a backend). However when I go to Setup backend and run the suggested command, it fails as mentioned above.

Until now I have only been using npx ampx sandbox for development and now I want to host it. But this manual step is a real DX let down 😕

The setup backend page seems a bit strange to me. Perhaps this flow needs a rethink.

image

ykethan commented 2 months ago

Hey folks, thank you for the information. The command allows generating the amplify_outputs.json for the frontend application to use if a Gen 2 backend has been deployed in the same app. If the Gen 2 backend was deployed in a different app you will need to reference the app-id and branch of the backend app to generate the file. Manual hosting currently does not support deploying Gen 2 backend resources, this is currently being tracked as a feature request: https://github.com/aws-amplify/amplify-backend/issues/775

passed this information to the Amplify team for improvements.

six-edge commented 2 months ago

It would be really nice just to be able to create backends via the CLI, without the requirement to use a VCS. Right now we are locked out of all these features because GitLab EE is not a supported VCS when creating an app in Amplify. Shame really as this is a no-go for us and all those businesses on GitHub enterprise too. We need to look at other solutions. Firebase has a great CLI BTW.

I would expect a command like this:

npx ampx backend create --stage dev

This would...

npx ampx frontend deploy --stage dev

That would...

With option to switch backends...

npx ampx backend switch --stage staging

DX could definitely be improved. Feel a bit frustrated and left out without GitLab integration 😞 difficult to sell it to management without those integrations.

tech-meppem commented 2 months ago

Manual hosting currently does not support deploying Gen 2 backend resources, this is currently being tracked as a feature request: #775

I think the page about setting up the backend is misleading and poorly worded then. https://eu-north-1.console.aws.amazon.com/amplify/apps/<appid>/branches/staging/backend-help

Manual deploy apps cannot be used to setup and manage a backend. To use this app with backend resources deployed elsewhere, follow the instructions below.

When step 3/3 of these instructions is:

Zip artifacts and deploy updates Make sure you zip the contents of your build output and not the top level folder, then deploy updates using the button below.

It makes it seem like that is all there is to do. As in, you just need to manually generate the amplify_outputs.json file. But the "deploy updates" button deploys to the current app, not a new one. So the "instructions below" are not actually doing anything to help you setup a backend.

I think I sort of understand the instructions a bit more now; it's instruction how to build your frontend to work with a backend. Not how to setup a backend.

But the page is called "Setup backend", and does not actually have instructions on how to setup the backend, so it is all very misleading.

moleCuleFFF commented 2 months ago

The time this has taken with us having to mirror our GitLab Enterprise repo into CodeCommit and then, due to needing to build, mirror our private npm registry into CodeArtifact

six-edge commented 1 month ago

The time this has taken with us having to mirror our GitLab Enterprise repo into CodeCommit and then, due to needing to build, mirror our private npm registry into CodeArtifact

CodeCommit is no longer available to new customers 🙄 https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider/

Checkmate for me ♟️

It would be nice to take a Heroku approach at least so I can push my code to a remote app so that it builds when I push to it.

luma-sb commented 1 day ago

The time this has taken with us having to mirror our GitLab Enterprise repo into CodeCommit and then, due to needing to build, mirror our private npm registry into CodeArtifact

CodeCommit is no longer available to new customers 🙄 https://aws.amazon.com/blogs/devops/how-to-migrate-your-aws-codecommit-repository-to-another-git-provider/

Checkmate for me ♟️

It would be nice to take a Heroku approach at least so I can push my code to a remote app so that it builds when I push to it.

This has impacted us here too - we thought we had AWS CodeCommit as a plan B if we couldn't get Azure DevOps Repos working - but no such luck.... so on to Plan C! Thankfully we have a GitHub organization I can mirror to but none of this is ideal. 🤢