ngrok / terraform-provider-ngrok

Ngrok exposes local servers behind NATs and firewalls to the public internet over secure tunnels. This provider helps you manage those resources via Terraform.
https://ngrok.com
MIT License
18 stars 1 forks source link

Clearing of domain output in 0.1.5 #28

Closed taiidani closed 11 months ago

taiidani commented 1 year ago

Expected

When upgrading from v0.1.4 of the provider to v0.1.5, the nginx_reserved_domain.resourcename.domain output continues to contain the computed domain name generated by the resource.

Actual

The domain output is null. Anything relying on the domain to be computed errors.

Example

resource "ngrok_reserved_domain" "example" {
  name        = "example-box-no-dot"
  description = "example instance"
}

output "instance_address" {
  value       = "https://${ngrok_reserved_domain.example.domain}"
  description = "The full URL including scheme for the ngrok domain reserved for this instance"
}
# 0.1.4 (New)
...
Changes to Outputs:
  + instance_address = (known after apply)

# 0.1.4 (Existing)
$ terraform plan
...
No changes. Your infrastructure matches the configuration.

# 0.1.5 (New or Existing)
$ terraform plan
...
 Error: Invalid template interpolation value
│ 
│   on ../../outputs.tf line 12, in output "instance_address":
│   12:   value       = "https://${ngrok_reserved_domain.example.domain}"
│     ├────────────────
│     │ ngrok_reserved_domain.example.domain is null
│ 
│ The expression result is null. Cannot include a null value in a string
│ template.
taiidani commented 1 year ago

Additional behavior that seems to come out of this change. According to v0.1.5's documentation all fields are now Optional, but this doesn't seem to be the case:

resource "ngrok_reserved_domain" "example" {}

terraform {
  required_providers {
    ngrok = {
      source  = "ngrok/ngrok"
      version = "0.1.5"
    }
  }
}

This snippet of TF cannot be applied:

$ terraform apply
...
Terraform will perform the following actions:

  # ngrok_reserved_domain.example will be created
  + resource "ngrok_reserved_domain" "example" {
      + acme_challenge_cname_target = (known after apply)
      + cname_target                = (known after apply)
      + id                          = (known after apply)
    }

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

...

ngrok_reserved_domain.example: Creating...
╷
│ Error: HTTP 400: The domain '' is not a fully qualified domain name. [ERR_NGROK_448]
│
│ Operation ID: op_2WdPPAju3ZY3Xe80lf24HtJWNIQ
│
│   with ngrok_reserved_domain.example,
│   on main.tf line 1, in resource "ngrok_reserved_domain" "example":
│    1: resource "ngrok_reserved_domain" "example" {}

If we provide name, the resource seems to go into an endless apply loop:

resource "ngrok_reserved_domain" "example" {
  name = "example-reserved-domain"
}

terraform {
  required_providers {
    ngrok = {
      source  = "ngrok/ngrok"
      version = "0.1.5"
    }
  }
}

Produces:

$ terraform apply
...
Terraform will perform the following actions:

  # ngrok_reserved_domain.example will be created
  + resource "ngrok_reserved_domain" "example" {
      + acme_challenge_cname_target = (known after apply)
      + cname_target                = (known after apply)
      + id                          = (known after apply)
      + name                        = "example-reserved-domain"
    }

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

...

ngrok_reserved_domain.example: Creating...
ngrok_reserved_domain.example: Creation complete after 0s [id=rd_2WdPfzcot94uKCUYY55DUrp5hdm]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

$ terraform apply
ngrok_reserved_domain.example: Refreshing state... [id=rd_2WdPfzcot94uKCUYY55DUrp5hdm]

Terraform will perform the following actions:

  # ngrok_reserved_domain.example must be replaced
-/+ resource "ngrok_reserved_domain" "example" {
      + acme_challenge_cname_target = (known after apply)
      + cname_target                = (known after apply)
      - domain                      = "example-reserved-domain.ngrok.app" -> null # forces replacement
      ~ id                          = "rd_2WdPfzcot94uKCUYY55DUrp5hdm" -> (known after apply)
        name                        = "example-reserved-domain"
    }

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

...

ngrok_reserved_domain.example: Destroying... [id=rd_2WdPfzcot94uKCUYY55DUrp5hdm]
ngrok_reserved_domain.example: Destruction complete after 1s
ngrok_reserved_domain.example: Creating...
ngrok_reserved_domain.example: Creation complete after 0s [id=rd_2WdPgWl5TW6Z4aTAWjzcKgDkcCh]

Apply complete! Resources: 1 added, 0 changed, 1 destroyed.

Successive applies continue to show the resource as needing to be changed.

bobzilladev commented 11 months ago

Thank you for bringing this to our attention! The latest release v0.2.0 should take care of this issue, the changelog shows the changes that have been made, with an update for the v1.5.0 section for the unintentional loss of the computed property for domain which has now been restored.

I'll close out this issue, please reopen if it doesn't fix the problem you're running into. Thanks again for the feedback!