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

Database Users: Update settings independent of other user settings #1090

Conversation

dweinshenker
Copy link
Contributor

@dweinshenker dweinshenker commented Dec 8, 2023

What

  • Prevent changes to kafka user ACLs from replacing database user resources

Why

The ability to update settings, and thus kafka user ACLs, allows for user management without replacing the user resources. Replacement of user resources is especially painful given that it will generate a new password.

Testing

Ran acceptance tests

ok  	github.com/digitalocean/terraform-provider-digitalocean/digitalocean/certificate	(cached) [no tests to run]
=== RUN   TestAccDigitalOceanDatabaseUser_KafkaACLs
=== PAUSE TestAccDigitalOceanDatabaseUser_KafkaACLs
=== CONT  TestAccDigitalOceanDatabaseUser_KafkaACLs
--- PASS: TestAccDigitalOceanDatabaseUser_KafkaACLs (289.63s)

Making a change locally to a user's ACLs on a test cluster and running terraform plan shows the user resource not being replaced anymore

Terraform will perform the following actions:

  # digitalocean_database_user.kafka-acl-user-1 will be updated in-place
  ~ resource "digitalocean_database_user" "kafka-acl-user-1" {
        id         = "352c8602-261c-4c00-a2e2-0130f015e243/user/kafka-acl-user-1"
        name       = "kafka-acl-user-1"
        # (3 unchanged attributes hidden)

      ~ settings {
          ~ acl {
                id         = "acl47b234cbe22"
              ~ permission = "produce" -> "consume"
              ~ topic      = "topic-3" -> "topic-5"
            }

            # (1 unchanged block hidden)
        }
    }

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

──────────────────────────────────────────────────

Calling the DO API shows the updates taking place:

{
            "name": "kafka-acl-user-1",
            "role": "normal",
            "password": ".......",
            "settings": {
                "acl": [
                    {
                        "id": "acl47b2c79825a",
                        "permission": "consume",
                        "topic": "topic-5"
                    },
                    {
                        "id": "acl47b2c7c7b24",
                        "permission": "consume",
                        "topic": "topic-4"
                    }
                ]
            }
        }

@dweinshenker dweinshenker marked this pull request as ready for review December 8, 2023 01:44
Copy link
Member

@andrewsomething andrewsomething left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! 👍

@andrewsomething andrewsomething merged commit c732456 into digitalocean:main Dec 8, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants