aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.8k stars 820 forks source link

Amplify hosting not detected #13230

Open CGarces opened 9 months ago

CGarces commented 9 months ago

How did you install the Amplify CLI?

npm

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

v18.17.1

Amplify CLI Version

12.4.0

What operating system are you using?

Windows 10

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

Amplify hosting MAYBE was added from console?

Describe the bug

I have changed my application from angular to plain JS

The build and deploy works fine and I can see the new files, but I can fetch the old files from the angular version.

I have executed

amplify publish -c
🛑 Add hosting to your project before publishing your project
Command: amplify hosting add

It's and old Amplify inhalation and I'm not sure how the hosting was added.

Hosting add not works

amplify hosting add
√ Select the plugin module to execute · Hosting with Amplify Console (Managed hosting with custom domains, Continuous deployment)
You have already connected branches to your Amplify Console app. Please visit the Amplify Console to manage your branches.

Expected behavior

Some way to sync hosting options with amplify pull

Reproduction steps

I can't reproduce the error.

Project Identifier

e2a6b48c5b48584b6f1162da36d4e8de

Log output

``` # Put your logs below this line ```

Additional information

No response

Before submitting, please confirm:

ykethan commented 9 months ago

Hey @CGarces, thank you for reaching out. The issue occurs when the hosting category has been via the AWS console, running amplify pull does not pull the hosting config. Unfortunately this information is only captured when hosting is added to the project on amplify add hosting. marking this as bug for DX improvements.

CGarces commented 9 months ago

I have deatached the branch, and added again from CLI. but I can't execute amplify publish - c, only give the option of made a git push. I still have the problem of old content served from cloud front.

ykethan commented 9 months ago

Hey @CGarces, the Continuous deployment option relies on a version control system such as GitHub to commit your changes, where the Amplify hosting on AWS console picks up the commit and runs the build. If you are looking to manually publish without a git provider we can utilize the Manual deployment option Amazon CloudFront and S3 to host your static website.

Please refer to the following documentation providing this information. https://docs.amplify.aws/cli/hosting/hosting/#type-of-deployments https://docs.amplify.aws/cli/hosting/hosting/#amazon-s3-and-amazon-cloudfront

Additionally, the amplify publish does not support a -c flag and is ignored by the command. Could you point me to the resource that provides this information? command reference: https://docs.amplify.aws/cli/commands/hosting/

CGarces commented 9 months ago

Hi!

Cache Invalidation

If you select Amazon S3 & Amazon Cloudfront for hosting your Amplify project in the amplify add hosting flow, the frontend build artifacts will be uploaded to the S3 hosting bucket, and then if Amazon CloudFront is enabled along with it, the amplify publish command executed with the --invalidateCloudFront or -c flag will send an invalidation request to the Amazon CloudFront service to invalidate its cache.

I need to move to Amazon CloudFront and S3, due this problems and the cache miss, the managed cloudfront is useless to me.

ykethan commented 9 months ago

@CGarces really appreciate pointing this out. Are there are here any issues you are observing with the managed CloudFront so that i can reach out to our folks in the hosting team for any information.

CGarces commented 9 months ago

I have a open case with AWS 13848994171

Looks like cloudfront is using the old index.html and made a redirection (the old version was an standard Angular application with routing).

Also the bug https://github.com/aws-amplify/amplify-hosting/issues/2563 is another reason to stop using hosted app.

The comment from https://github.com/aws-amplify/amplify-hosting/issues/2563#issuecomment-1723204047 provide a lot of information about what is probably going wrong with my deploy.

But In any case the main topic of the issue "Amplify hosting not detected" is solved, so I'll close the issue.

github-actions[bot] commented 9 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

ykethan commented 9 months ago

@CGarces I understand. I am going to keep the issue open as this would enable us in tracking the CLI improvements on the hosting flow.