Create app from existing fly.toml?

I had an app that I destroyed due to problems during testing. Now I would like to recreate it.

However, whatever I try, it seems I’m not able to simply bootstrap the app from the existing toml file. Instead, the cli always tries to modify the toml in one way or other:

❯ fly init
***An existing configuration file has been found.
? Overwrite file '/htdocs/foo/fly.toml' No

❯ fly launch
An existing fly.toml file was found for app evcc
? Would you like to copy its configuration to the new app? (y/N)

Can I recreate an app from an existing toml?

You can recreate the app from existing toml by simply choosing yes to copy the configuration,
for example:

$ fly launch                                                                                                              master  ✱
An existing fly.toml file was found for app withered-meadow-6338
? Would you like to copy its configuration to the new app? Yes
Creating app in /go-example
Scanning source code
Detected Go app
Using the following build configuration:
	Builder: paketobuildpacks/builder:base

Unfortunately, this will create a new app with an arbitrary (domain) name- exactly what I want to avoid! The toml already has the app name and exactly that should be recreated.

Oh you want to just recreate the original app? Try fly launch --name <name> with the fly.toml in place.

I would have expected fly launch to just leave the toml alone and launch it, but by adding name plus agree to copy it’s working as desired.

Much appreciated, thank you!

I probably agree with you. The fly launch UX is something we’re still working through, it would make sense to use that app name if it doesn’t exist already.

1 Like

Worth noting: one reason I had to scrap the app to start from scratch was that the ENV settings from the toml did not get updated. My app was constantly seeing an old ENV setting even when I rebuilt/deployed the container. After destroy/launch I’m getting the new settings. Seems there is something odd in the deploy process with toml-supplied environment.

Is it possible you had a secret set with the same name? Secrets will stomp on env variables defined in the config file.

Ahh, quite possible. Might be nice to log such clash?

In the fly.toml env vars section, it is mentioned:

Where there is a secret and an env variable set with the same name, the secret will take precedence.

You can list all environment variables (including secrets) with fly config env

1 Like