Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionoscloud_container_registry considered as created before it is fully ready #607

Closed
skoenig opened this issue Jul 17, 2024 · 0 comments · Fixed by #620
Closed

ionoscloud_container_registry considered as created before it is fully ready #607

skoenig opened this issue Jul 17, 2024 · 0 comments · Fixed by #620
Assignees
Labels
bug Something isn't working

Comments

@skoenig
Copy link
Contributor

skoenig commented Jul 17, 2024

Description

When creating an IONOS Cloud Container Registry using the Terraform provider, the hostname attribute is not available. This causes issues with configurations that depend on the hostname attribute being available immediately after the resource is created.

Expected behavior

The Terraform provider should only consider the ionoscloud_container_registry as created if it is actually available and ready to use (not in the 'WaitingForStorage' state anymore) and all its attributes are set.

Environment

Terraform version:

1.5.7

Provider version:

v6.4.18

OS:

Alpine Linux v3.18 (Terraform's official Docker image https://hub.docker.com/r/hashicorp/terraform)

Configuration Files

terraform {
  required_providers {
    ionoscloud = {
      source  = "ionos-cloud/ionoscloud"
      version = "6.4.18"
    }
  }
}

resource "ionoscloud_container_registry" "registry" {
  name     = "cr-bug-report"
  location = "de/fra"
  garbage_collection_schedule {
    days = ["Monday"]
    time = "06:00:00+00:00"
  }
  features {
    vulnerability_scanning = false
  }
}

data "ionoscloud_container_registry" "registry" {
  depends_on = [ionoscloud_container_registry.registry]
  name = "cr-bug-report"
}

resource "null_resource" "test" {
  depends_on = [data.ionoscloud_container_registry.registry]

  triggers = {
    always_run = timestamp()
  }
  provisioner "local-exec" {
    command = "echo container registry hostname: '${data.ionoscloud_container_registry.registry.hostname}'"
  }
}

How to Reproduce

  1. terraform init && terraform plan && terraform apply -auto-approve
  2. Immediately try to access the hostname attribute of the container registry.

Error and Debug Output

terraform apply output (note that the hostname value is an empty string):

<skipped for brevity>
Plan: 2 to add, 0 to change, 0 to destroy.
ionoscloud_container_registry.registry: Creating...
ionoscloud_container_registry.registry: Creation complete after 7s [id=f14425ec-071e-440b-b60a-f8ea965e37e2]
data.ionoscloud_container_registry.registry: Reading...
data.ionoscloud_container_registry.registry: Read complete after 2s [id=f14425ec-071e-440b-b60a-f8ea965e37e2]
null_resource.test: Creating...
null_resource.test: Provisioning with 'local-exec'...
null_resource.test (local-exec): Executing: ["/bin/sh" "-c" "echo container registry hostname: ''"]
null_resource.test (local-exec): container registry hostname:
null_resource.test: Creation complete after 0s [id=1638570349943663561]
<skipped for brevity>

Accessing the state:

$ terraform state show ionoscloud_container_registry.registry
# ionoscloud_container_registry.registry:
resource "ionoscloud_container_registry" "registry" {
    id            = "a92abcee-4265-4b3d-afd3-1cdd4ac6aa7d"
    location      = "de/fra"
    name          = "cr-bug-report"
    storage_usage = [
        {
            bytes      = 0
            updated_at = ""
        },
    ]

    features {
        vulnerability_scanning = false
    }

    garbage_collection_schedule {
        days = [
            "Monday",
        ]
        time = "06:00:00+00:00"
    }
}

$ terraform state show data.ionoscloud_container_registry.registry
# data.ionoscloud_container_registry.registry:
data "ionoscloud_container_registry" "registry" {
    features                    = [
        {
            vulnerability_scanning = false
        },
    ]
    garbage_collection_schedule = [
        {
            days = [
                "Monday",
            ]
            time = "06:00:00+00:00"
        },
    ]
    id                          = "a92abcee-4265-4b3d-afd3-1cdd4ac6aa7d"
    location                    = "de/fra"
    name                        = "cr-bug-report"
    partial_match               = false
    storage_usage               = [
        {
            bytes      = 0
            updated_at = ""
        },
    ]
}

Additional Notes

I am fully aware that this is an eventual consistency error, but I believe it is better for the Terraform provider to ensure that created resources are actually ready to use before considering them as created. This would help prevent issues with dependent resources and provisioners that rely on the resource being fully available and all its attributes being set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants