DAlperin / terraform-provider-fly-io

Mozilla Public License 2.0
9 stars 2 forks source link

Data source fly-io_ip fails #12

Open hb9cwp opened 2 years ago

hb9cwp commented 2 years ago

After appending the fragment below to the "known-good" example.tf shown over in Issue #11 , terraform apply fails. terraform validate does not complain, and I cannot see any syntax error either:

$ terraform apply
data.fly_ip.exampleIPv4: Reading...
data.fly_app.exampleApp: Reading...
data.fly_cert.exampleCert: Reading...
data.fly_app.exampleApp: Read complete after 1s [id=https-helloworld-11]
data.fly_cert.exampleCert: Read complete after 7s [id=cert_9k05g]
╷
│ Error: Could not find IPAssignment
│ 
│   with data.fly_ip.exampleIPv4,
│   on https-helloworld_cert.tf line 65, in data "fly_ip" "exampleIPv4":
│   65: data "fly_ip" "exampleIPv4" {
│ 
│ app.ipAddress

Append to example.tf from Issue #11

...
data "fly_ip" "exampleIPv4" {
  # https://registry.terraform.io/providers/DAlperin/fly-io/latest/docs/data-sources/ip
  app = "https-helloworld-11"
  type = "v4"
}

# sections commented to isolate issue to data section above:
#output "Data_IPv4" {
#  value = data.fly_ip.exampleIPv4
#}

#output "Data_IPv4_address" {
#  value = data.fly_ip.exampleIPv4.address
#}
hb9cwp commented 2 years ago

Currently, the app has several IP addresses, but I did not allocate any IPs to it:

$ fly ips list
TYPE ADDRESS             REGION CREATED AT           
v4   37.16.a.b         global 4h18m ago            
v4   37.16.c.d         global 2022-05-19T07:14:49Z 
v6   2a09:8280:1::x:y global 2022-05-19T07:14:49Z 
v6   2a09:8280:1::y:z global 2h42m ago            

$ fly ips private
  ID       | REGION | IP                                
-----------*--------*-----------------------------------
  3ccxxxx | fra    | fdaa:0:....  
DAlperin commented 2 years ago

Hmmm, it works for me. Though one thought I have is that you don't have depends_on set on any resources that depend on the main app. That ensures the main app gets created/reconciled first. See https://github.com/DAlperin/terraform-provider-fly-io/blob/main/examples/main.tf for an example. Let me know what you find.