Skip to content
This repository has been archived by the owner on Mar 1, 2024. It is now read-only.

fly_machine.mounts.volume should only accept fly_volume.id, not fly_volume.name #168

Open
oscarhermoso opened this issue Apr 29, 2023 · 0 comments

Comments

@oscarhermoso
Copy link

oscarhermoso commented Apr 29, 2023

Currently, the terraform docs state that the volume name can be used to identify the volume for the fly_machine. While this is partially true (resource is created on fly.io), it leaves terraform in a broken state.

https://registry.terraform.io/providers/fly-apps/fly/latest/docs/resources/machine

volume (String) Name or ID of volume

Steps to reproduce:

Define as follows:

mounts = [{
    volume = fly_volume.app.name
    path   = "/data"
  }]

Result

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
  ~ update in-place

Terraform will perform the following actions:

# module.redis.fly_machine.app["syd"] will be updated in-place
  ~ resource "fly_machine" "app" {
      ~ cputype   = "shared" -> (known after apply)
      ~ id        = "*************" -> (known after apply)
      ~ mounts    = [
          ~ {
              ~ encrypted = true -> (known after apply)
              ~ size_gb   = 1 -> (known after apply)
              ~ volume    = "vol_2yxp4mnk2z3r63qd" -> "org_app_dev_syd"
                # (1 unchanged attribute hidden)
            },
        ]
        name      = "org-app-dev-syd"
      ~ privateip = ""*************" -> (known after apply)
        # (6 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

Error: Provider produced inconsistent result after apply
│ When applying changes to module.redis.fly_machine.app["syd"], provider "provider[\"registry.terraform.io/fly-apps/fly\"]" produced an
│ unexpected new value: .mounts[0].volume: was cty.StringVal("org_app_dev_syd"), but now cty.StringVal("vol_2yxp4mnk2z3r63qd").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.

Workaround/resolution

  • terraform destroy and then
  • Define as follows:
mounts = [{
    volume = fly_volume.app.id  // <!-- specify .id instead of .name
    path   = "/data"
  }]
  • terraform apply

Ideally the docs (and possibly the code) are updated to reflect that the fly_volume id should be used instead of name for mounts.

@oscarhermoso oscarhermoso changed the title fly_machine.mounts.volume Volume should not accept name or ID fly_machine.mounts.volume Volume should not accept name Apr 29, 2023
@oscarhermoso oscarhermoso changed the title fly_machine.mounts.volume Volume should not accept name fly_machine.mounts.volume should only accept fly_voume.id, not fly_voume.name Apr 29, 2023
@oscarhermoso oscarhermoso changed the title fly_machine.mounts.volume should only accept fly_voume.id, not fly_voume.name fly_machine.mounts.volume should only accept fly_volume.id, not fly_volume.name Apr 29, 2023
@andrewbaxter andrewbaxter mentioned this issue Dec 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant