digitalocean / terraform-provider-digitalocean

Terraform DigitalOcean provider
https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs
Mozilla Public License 2.0
509 stars 278 forks source link

database_replica's URN not available #1242

Open renanbr opened 1 month ago

renanbr commented 1 month ago

Bug Report

I'm importing existing resources.

When defining a project where I would like to attach the replica, URN isn't available.

resource "digitalocean_project" "default" {
  // ...
  resources = [
    // ....
    digitalocean_database_replica.mysql_read_only.urn,
  ]
}

Describe the bug

The apply command doesn't work.

Affected Resource(s)

Expected Behavior

Having the replace attached to the project.

Actual Behavior

│ Error: Unsupported attribute
│
│   on application/project.tf line 8, in resource "digitalocean_project" "default":
│    8:     digitalocean_database_replica.mysql_read_only.urn,
│
│ This object has no argument, nested block, or exported attribute named "urn". Did you mean "uri"?

Steps to Reproduce

  1. Define a digitalocean_project resource
  2. Define a digitalocean_database_cluster resource
  3. Define a digitalocean_database_replica resource
  4. Attach the replica as resource of a digitalocean_project resource
  5. Run terraform apply

Terraform Configuration Files

provider "registry.terraform.io/digitalocean/digitalocean" {
  version     = "2.42.0"
  constraints = "~> 2.0"
  // ...
}

Terraform version

Terraform v1.9.6
on darwin_arm64

Debug Output

none

Panic Output

none

Additional context

I'm currently interpolating the id when attaching it to the project.

"do:dbaas:${digitalocean_database_replica.mysql_read_only.uuid}"

Important Factoids

I'm aware about the solution found in #639

References

none

loosla commented 1 month ago

Hi Renan,

Thank you for your feedback regarding the use of project resources in our API. I appreciate your input.

A bit more context about the issue:

digitalocean_project_resources requires resources to follow urn format: api doc. Using raw uuid instead of urn or anything that doesn't follow the urn format triggers an error on terraform apply:

Error: Error creating Project: Error assigning resources: POST https://api.digitalocean.com/v2/projects/34f99b72-4f48-49c1-bc2d-48722a56997a/resources: 400 (request "abc123") resource objects must have an urn in the following format: do:resource_type:resource_id

I appreciate you bringing this to our attention. I’ll need to discuss it with the team to determine the priority and the best approach to enhance the user experience.