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

`amplify push` doesn't read from `backend-config`, but does read from `amplify-meta`

Open nagey opened this issue 5 years ago • 12 comments

Describe the bug When running amplify push I expect it to consult the backend-config.json file, especially the dependsOn array for various services.

Apparently though, running amplify env checkout … is the magic sauce to convert the items in backend-config into amplify-meta.

Amplify CLI Version 4.13.1

To Reproduce

  1. Make a change to your backend-config.json.
  2. Push to the cloud.
  3. Stare at your cloudformation stacks in the console, wonder why change isn't being reflected
  4. Deliberately break backend-config.json
  5. push to the cloud. not broken.
  6. google a bunch of things
  7. get frustrated
  8. have dinner
  9. come back, and repeat steps 1-7
  10. On a whim, look at amplify-meta.json and see that while it's out of sync with your backend-config.json it's strangely in sync with what seems to be happening in the CF Template.
  11. Finally have someone point out to you the 4th item #1 under https://aws-amplify.github.io/docs/cli-toolchain/quickstart#custom-cloudformation-stacks and see the bit about having to run amplify env checkout … to get amplify to read the changes on your local system

Expected behavior The build processes associated with amplify push should read backend-config in a similar fashion to how it reads all of the various cloudformation templates, schemas, functions, and everything else that're kept in source control.

Additional context I would really like to get these three hours back, but they're gone forever, sitting contently in a nice crowded room with all of the other (numerous) hours that I've lost to poorly documented, or buggy, pieces of the amplify codebase.

nagey avatar Feb 14 '20 02:02 nagey

Preemptively sorry for my semi sarcastic tone in my steps to repro, but this was an extremely frustrating thing to find, and honestly makes no sense to me as to why it is done this way.

If there’s a compelling reason that it is the way it is, could there at least be a comment put into the backend config that it only gets read when you do an env pull?

nagey avatar Feb 14 '20 05:02 nagey

Hi @nagey we generally don't recommend modifying those files manually. Can you give us more information on what you were trying to do?

ammarkarachi avatar Feb 14 '20 18:02 ammarkarachi

"generally don't recommend"? image

Unless you mean modifying amplify-meta, which, yeah, I get. I was trying to pipe the endpoint URL of one of the rest services into a function, rather than just the endpoints "friendly" name.

nagey avatar Feb 14 '20 20:02 nagey

@nagey Yes, the amplify-meta.json are runtime files which should not be modified. But yes, you're right the backend-config.json has to be modified for adding custom resources/categories. And yes, as mentioned in step #4 of our documentation, we've mentioned to run amplify env checkout <env-name> after making any changes to your backend-config.json. But at the same time, I agree this could be a part of your amplify push process to make the experience better.

kaustavghosh06 avatar Feb 24 '20 22:02 kaustavghosh06

@kaustavghosh06 I've made sure to add the checkout step to our workflow when changing resources, but would love to hear it getting added to the amplify push

nagey avatar Feb 26 '20 18:02 nagey

wow. thanks for this... spent hours trying to figure out why suddenly adding sns to backend-config doesn't work... lol

goes into readme: run amplify env checkout after making any changes to your backend-config.json

asmajlovicmars avatar Jun 26 '20 13:06 asmajlovicmars

I have had same issue today, even you don't have to go to aws console, you can see in your terminal output that there is nothing to push.

I executed amplify env checkout irfansenv and then tried amplify push again, then amplify finally asked me if I want to continue.

$ amplify -v 4.32.1

irfan avatar Nov 23 '20 05:11 irfan

Please, please, please add it to the ' amplify push' flow. I do have a reminder to run amplify env pull before an amplify push- but I still keep forgetting about it and need more time than it should to figure out why things don't work. THANKS <3

AndreasEK avatar Jun 08 '21 14:06 AndreasEK

Hi there!

This is still very much an issue. Lost hours trying to figure it out. It makes no sense that we have to run amplify env checkout every time we push. At the beginning of the amplify push, it absolutely should do that comparison and update amplify meta based on the content of the backend config.json.

Thanks

ldaudet avatar Sep 06 '21 00:09 ldaudet

I have a custom stack to take care of assigning permissions to my Cognito user groups and Lambda functions. This issue bit me 6 months ago, today I added a new Lambda function and it bites me again. I've lost at least a day because of this...

backend-config.json is not a file developers update everyday, WHO ON EARTH WOULD REMEMBER TO RUN amplify env checkout AFTER SIX MONTHS??!!

amplify push should update amplify-meta.json automatically! Does it make sense for anyone to update backend-config.json but not want the change to take effect the next time they push? If making it fully automatic is not possible (I'd love to know why), the push command should at least check if backend-config.json has been updated and warn the user in bold red text to run checkout.

Before Amplify fixes this problem, for anyone who wants to add a reminder for themselves, you can comment in backend-config.json, for example I added the following comment to mine:

// "ALWAYS RUN `amplify env checkout <env>` AFTER UPDATING THIS FILE OR THE CHANGE WILL NOT TAKE EFFECT":
// "See: https://github.com/aws-amplify/amplify-cli/issues/3426",
{
  ... file content ...
}

a9udn9u avatar Feb 04 '22 07:02 a9udn9u

I just burned 6 hours on similar problem, it was a badly performd merge (from a conflict) on backend-config.json that got me.

amplify push should rebuild everything and not leave some changes unbuilt.

pszabop avatar Jul 06 '22 08:07 pszabop

[...] But at the same time, I agree this could be a part of your amplify push process to make the experience better.

@kaustavghosh06 any update on this? 2 years after your messages and amplify-meta.json is still not updated after amplify push

dral3x avatar Jul 29 '22 08:07 dral3x

I just burned 8 hours on this issue. Can we please prioritize to update amplify-meta.json on amplify push

Jeevantk avatar Nov 11 '22 14:11 Jeevantk

Is it not about this? https://github.com/aws-amplify/amplify-cli/issues/9941#issuecomment-1063231806

JosueBCe avatar Nov 26 '22 03:11 JosueBCe

Here there's a solution https://github.com/aws-amplify/amplify-cli/issues/8608#issuecomment-1086890943

JosueBCe avatar Nov 26 '22 14:11 JosueBCe

I just burned 8 hours on this issue. Can we please prioritize updating Worked for me @Jeevantk https://github.com/aws-amplify/amplify-cli/issues/8608#issuecomment-1086890943 amplify-meta.json on amplify push

JosueBCe avatar Nov 26 '22 14:11 JosueBCe