Open oscarhermoso opened 2 days ago
Thanks for the report and the thorough research!
Interesting, I just checked the rest api and it seems to still show image
at the root: https://fly.io/docs/machines/api/machines-resource/#create-a-machine - AFAICT flyctl
which uses fly-go
(I think?) also has it in the same place: https://github.com/superfly/fly-go/blob/main/machine_types.go#L670
If it's not too much to ask, can you check the http requests like in https://github.com/andrewbaxter/terraform-provider-fly?tab=readme-ov-file#tips-for-adding-functionality ? It might be obvious from that, and I might not have time right away but I can creating a machine in flyctl with http logging on for comparison at some point too.
Also is there a flyctl
command to get the machine details? What does it say for the image when you run that?
FWIW I'm not familiar with using fly deploy
in conjunction with terraform. My guess is that it builds, uploads the docker image, then changes the image
property of the machine to point to the uploaded image, in which case I'd expect that error regardless.
I'm straying further and further here, but when I was doing stuff I used terraform to build and upload the image with the image linked to the fly machine and that seemed to work well (of course, long ago, so if the api has changed that's fairly irrelevant now).
My proposed solution does not work.
I first attempted moving "image"
inside of a new "build"
struct` - but this fails with a 400 response (same as https://github.com/andrewbaxter/terraform-provider-fly/issues/9)
I have also tried including "image": "..."
and "build": { "image": "..." }
in the same payload - this successfully deploys but the Configuration page of the Fly.io dashboard is still missing the image = "..."
I will add logging for HTTP requests and see what I can find.
Interesting, sorry I don't have a good answer for you here. Keep me posted though and I'll help where I can.
Steps to reproduce
Given Terraform like below:
Expected
Expect that after deployment, the build is included in the Configuration shown on the dashboard
Actual
Build is missing from the output
This causes following issues if you try to issue a
fly deploy
command from the CLI without afly.toml
I believe this is caused by the fact that image is specified at the top level - but it actually needs to be defined within build:
https://github.com/andrewbaxter/terraform-provider-fly/blob/bf858c979e73627cb1c22c0d10461e6d211d0b92/machineapi/machines.go#L81-L91
https://fly.io/docs/reference/configuration/#specify-a-docker-image
I imagine this used to work but Fly changed the API at some point in time.