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

Support for sql_require_primary_key in digitalocean_database_cluster #998

Closed
spantaleev opened this issue Jun 17, 2023 · 2 comments
Closed
Labels
api-parity Feature supported in the DigitalOcean API not yet implemented in Terraform hacktoberfest

Comments

@spantaleev
Copy link

Is your feature request related to a problem? Please describe.

I have an application which requires a MySQL database instance running with sql_require_primary_key=false.

The default value for a Digital Ocean MySQL database is true.

Changing the sql_require_primary_key configuration via the API is possible: curl -H 'Authorization: Bearer XXX' -XPATCH --data '{"config": {"sql_require_primary_key": false}}' https://api.digitalocean.com/v2/databases/{YOUR_DATABASE_CLUSER_ID}/config).

It'd be more convenient if this could be done via the digitalocean_database_cluster resource.

Describe the solution you'd like

A new sql_require_primary_key field may be added to the digitalocean_database_cluster resource which would influence the sql_require_primary_key configuration setting.

Describe alternatives you've considered

For now, I'm changing sql_require_primary_key manually via the API, outside of Terraform.

My manual changes do not seem to get undone by subsequent Terraform runs, so it's usable.

@danaelhe danaelhe added the api-parity Feature supported in the DigitalOcean API not yet implemented in Terraform label Jun 20, 2023
@dvigueras
Copy link

I have the same problem and I solved it with a temporary workaround using the Mastercard/restapi provider:

# Configure the RestAPI provider
provider "restapi" {
  uri = "https://api.digitalocean.com/"

  headers = {
    "Authorization" = format("Bearer %s", var.do_token)
    "Content-Type"  = "application/json"
  }

  create_returns_object = false
  write_returns_object = false
  debug = true
}

resource "restapi_object" "myproject-mysql-extra-config" {
  path = "/v2/databases/{id}/config"
  read_path = "/v2/databases/{id}/config"
  create_method  = "PATCH"
  create_path = "/v2/databases/{id}/config"
  update_method  = "PATCH"
  update_path = "/v2/databases/{id}/config"
  destroy_method = "GET"
  destroy_path = "/v2/databases/{id}/config"
  id_attribute = digitalocean_database_cluster.myproject-mysql.id
  object_id = digitalocean_database_cluster.myproject-mysql.id
  data = "{\"config\": { \"sql_require_primary_key\": false }}"
}

It would be great to have a new digitalocean_database_config resource so that it could be possible to do this:

resource "digitalocean_database_config" "database-config-example" {
  cluster_id = digitalocean_database_cluster.mysql-example.id
  sql_require_primary_key = false
}

Right now the DO API has two endpoints:

If these two endpoints are enough to create the new resource I am open to create a new PR with this new resource and at least the sql_require_primary_key parameter. Later it could be upgraded with other config parameters.

@loosla
Copy link
Contributor

loosla commented Sep 16, 2024

Done in #1051

@loosla loosla closed this as completed Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-parity Feature supported in the DigitalOcean API not yet implemented in Terraform hacktoberfest
Projects
None yet
Development

No branches or pull requests

4 participants