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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql grants delete old grants when adding an extra grant #104

Open
jwtje opened this issue Dec 20, 2021 · 2 comments
Open

Mysql grants delete old grants when adding an extra grant #104

jwtje opened this issue Dec 20, 2021 · 2 comments
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@jwtje
Copy link

jwtje commented Dec 20, 2021

Hello!

  • Vote on this issue by adding a 馃憤 reaction
  • To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)

Issue details

When adding a grant with pulumi-mysql like this:

mysql.Grant(f"mysql-grant-{username}",
        database="*",
        user=username,
        host="%",
        privileges=[
            "SELECT",
            "INSERT",
            "UPDATE",
            "DELETE",
            "CREATE",
            "ALTER",
            "INDEX",
            "REFERENCES",
            "PROCESS"
        ],
        opts=pulumi.ResourceOptions(provider=mysql_provider, parent=user)
    )

and adding an extra privilege later all the priviliges set before the update will be removed.

Steps to reproduce

  1. create a privilege set see above.
  2. add another privilege to the list.

pulumi output:

pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:prod::accounting::pulumi:pulumi:Stack::accounting-prod]
    > pulumi:pulumi:StackReference: (read)
        [id=buckaroo/prod-v1/prod]
        [urn=urn:pulumi:prod::accounting::pulumi:pulumi:StackReference::buckaroo/prod-v1/prod]
        name: "buckaroo/prod-v1/prod"
        ++mysql:index/grant:Grant: (create-replacement)
            [id=iam_admin@%:*]
            [urn=urn:pulumi:prod::accounting::mysql:index/user:User$mysql:index/grant:Grant::mysql-grant-iam_admin]
            [provider=urn:pulumi:prod::accounting::pulumi:providers:mysql::accounting-prod-rds-root-provider::9efc35f9-e93e-4cf7-8d8b-c53456753faa]
          ~ privileges: [
                [0]: <null>
                [1]: <null>
                [2]: <null>
                [3]: <null>
                [4]: <null>
                [5]: <null>
                [6]: <null>
                [7]: <null>
              + [8]: "PROCESS"
            ]
        +-mysql:index/grant:Grant: (replace)
            [id=iam_admin@%:*]
            [urn=urn:pulumi:prod::accounting::mysql:index/user:User$mysql:index/grant:Grant::mysql-grant-iam_admin]
            [provider=urn:pulumi:prod::accounting::pulumi:providers:mysql::accounting-prod-rds-root-provider::9efc35f9-e93e-4cf7-8d8b-c53456753faa]
          ~ privileges: [
                [0]: <null>
                [1]: <null>
                [2]: <null>
                [3]: <null>
                [4]: <null>
                [5]: <null>
                [6]: <null>
                [7]: <null>
              + [8]: "PROCESS"
            ]
        --outputs:--

Expected: A privilege added but initial privileges intact
Actual: old priviliges removed, new privilige added.

@jwtje jwtje added the kind/bug Some behavior is incorrect or out of spec label Dec 20, 2021
@leezen
Copy link

leezen commented Dec 23, 2021

@stack72 While not directly related to the bug described above, I wonder if it would make sense to have this provider track https://github.com/winebarrel/terraform-provider-mysql instead? It's continuing to be updated (vs. the current upstream which is in archive mode) and has added functionality such as winebarrel/terraform-provider-mysql#20 to support updating grants vs. having to replace them.

@Sefiris
Copy link

Sefiris commented Aug 12, 2022

馃憤

Currently we have to work around this by using a opts=ResourceOptions(replace_on_changes=["privileges"]), but i have to hope this is not intended. as it feels ridiculously dirty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

3 participants