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

Clone backend environment fails, no usable message/logs for troubleshooting

Open lcastillo84 opened this issue 2 years ago • 12 comments

Before opening, please confirm:

App Id

d1l6t49c3tjdqv

Region

us-east-1

Amplify Hosting feature

Backend builds

Describe the bug

Hi!

I've created a new dev backend environment running a simple set of resources: Auth, GraphQL and Rest APIs and a Python Lambda function.

image

When I attempt to clone the environment in the AWS Amplify Console, I'm getting a generic "cloning backend failed" message without indication of the reason of the problem.

image

Afterwards a new empty backend environment is created:"

image

The deployment tab for the new environment doesn't show much information:

image

I've tried a couple of times but so far haven't been able to successfully clone the environment. I don't see any useful information in the Amplify Console interface that would allow me to identify the reason of the issue. Please note that I actually attempted re-creating the app from scratch (creating all resources via the amplify cli), bus the issue still occurred.

Thank you in advance for your feedback!

Expected behavior

The dev backend is cloned successfully into a new production environment, including all the relevant resources: Auth, APIs and functions.

Alternately, I get a useful message indicating the reason why the backend cloning failed.

Reproduction steps

  1. Open amplify console.
  2. In Backend Environments / dev environment, click actions -> Clone. The following message appears: "Cloning env:dev to env: production in app:d1l6t49c3tjdqv. This operation will take a few minutes."
  3. After a minute, the following message appears: "Cloning env:dev to env: production in app:d1l6t49c3tjdqv failed"

Build Settings

No response

Additional information

No response

lcastillo84 avatar Oct 05 '22 14:10 lcastillo84

Hi @lcastillo84 👋🏽 thanks for reaching out for this issue. I was able to reproduce this behavior in my account. We are looking to see if there is a possible workaround for this. We will respond with an update shortly.

ghost avatar Oct 05 '22 23:10 ghost

Hi @hloriana, I had to delete the app and recreate it. New id is d1bfim7r26ufoo. The issue still occurs

lcastillo84 avatar Oct 10 '22 13:10 lcastillo84

Hi @lcastillo84 this appears to be a transient issue because I tried again as well but it went through this time. We are working root causing the behavior. In the mean time, you can also try to clone your backend using this AWS CLI command:

aws amplify clone-backend --app-id <value> --backend-environment-name <value> --target-environment-name <value>

Please let us know if this command works for you.

Edit: Also make sure that you have successfully added a service role to your Amplify app to allow for the creation of backend resources: https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html. Without this role, Amplify will not have permissions to create backend resources.

ghost avatar Oct 13 '22 20:10 ghost

Hi @lcastillo84 this appears to be a transient issue because I tried again as well but it went through this time. We are working root causing the behavior. In the mean time, you can also try to clone your backend using this AWS CLI command:

aws amplify clone-backend --app-id <value> --backend-environment-name <value> --target-environment-name <value>

Please let us know if this command works for you. I am also facing a similar issue cloning the amplify backend from the console.

Edit: Also make sure that you have successfully added a service role to your Amplify app to allow for the creation of backend resources: https://docs.aws.amazon.com/amplify/latest/userguide/how-to-service-role-amplify-console.html. Without this role, Amplify will not have permissions to create backend resources.

@hloriana

I tried running aws amplifybackend clone-backend --app-id <value> --backend-environment-name <value> --target-environment-name <value> instead but I get the following error:

An error occurred (ValidationException) when calling the CloneBackend operation: ValidationException - An error occurred while processing your request: appId and backendEnvironmentName are required.

tangytang avatar Nov 03 '22 04:11 tangytang

When I try the CLI clone command (aws amplify clone-backend --app-id --backend-environment-name --target-environment-name ) I get the following message:

aws: error: argument operation: Invalid choice, valid choices are:...

I am using version 10.6.2 of the Amplify CLI.

I have never been able to successfully clone an Amplify environment other than a trivial one provided in a tutorial. AWS should either make this feature work or remove it.

defish1962 avatar Jan 28 '23 20:01 defish1962

I also am coming across this issue in the UI. I will try the CLI command as well.

willb0246 avatar May 07 '23 22:05 willb0246

Hi there, are you guys still working on this issue? I've tried with various methods what I could find, but none of them solved the issue or gave me clue.

sprisao avatar May 29 '23 01:05 sprisao

The best way to clone an environment is to branch your code, change to that branch, and then run the amplify init command. When it prompts you if you want to initialize an existing environment, answer no, enter the name for your new environment and then finish walking through the initialization prompts. After it completes, confirm you are in the new environment with amplify env list, and then do an amplify push.

defish1962 avatar May 29 '23 12:05 defish1962

Hey, @defish1962 thank you for your suggestion, but it create then new application not "new environment" 😩 Did I miss something or did you just mean it?

sprisao avatar Jun 08 '23 08:06 sprisao

@sprisao sorry if I caused any confusion. It should work to create a new environment in an existing project or app. You need to make sure that your front end is currently connected to an existing amplify environment, then follow the steps below.

Let's say I have an environment named dev, and want to create an environment named test I create a git branch from dev named test. I change to that branch in my code editor (VS Code). I will still be pointing to the Amplify dev environment in my app folder. Confirm that by entering amplify env list. You should see an * next to the current environment name

Run the amplify init command. You will be asked if. you want to use an existing environment. Say No.

You will then be prompted to enter a name for the environment. Enter test (or whatever name you want to use)

You will be prompted to select the authentication method you want to use. I chose Amplify Studio.

It should then start creating a new environment in your existing application. You should see a message like this:

Adding backend environment pilot to AWS Amplify app: <APP ID>

Follow any remaining prompts and it should complete the process with a new, empty environment.

At that point run amplify push and you should end up with a cloned environment.

If for some reason your computer isn't configured for an existing amplify application, you can initialize it and pull the existing backend into your front end environment.

If the team-provider-info.json file is missing:

  1. Backup and remove the amplify folder
  2. Pull the environment from the root of your project folder using the amplify pull --appId --envName  command displayed in the Amplify Console for your application

Hope this helps.

defish1962 avatar Jun 08 '23 14:06 defish1962

@defish1962 thank you so much for Your detailed and helpful instructions! It allowed me to successfully clone the env. Thank you 😊

sprisao avatar Jun 09 '23 08:06 sprisao

I had the same problem, and removing analytics and notifications fixed it for me (I'm not sure which one cause the issue). I could easily clone the env from the Amplify console.

alpha-adam avatar Dec 20 '23 12:12 alpha-adam

Hello @defish1962,

I wanted to pause from my work to express my gratitude to you. I've been tirelessly working for a week straight, and neither the documentation nor AWS technical support offered much assistance. Your help has been invaluable. Thank you, brother!

Bereket-Desbele avatar Feb 18 '24 21:02 Bereket-Desbele