Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

redshift_grants resource occasionally shows incorrect diffs or permanent diffs #24

@viktorradnai

Description

@viktorradnai

This issue also affects redshift_permissions but we have migrated to redshift_grants so haven't created a test case for that.

The code used to check grants consists of SQL functions like these:

decode(charindex('r',split_part(split_part(array_to_string(relacl, '|'),gr.groname,2 ) ,'/',1)), 0,0,1) as select,

This is imperfect and gets confused in a number of cases. It's meant to parse ACLs like these:

{"group my_reader_group=r/my_user",my_user=arwdRxtD/myuser}

These have the format of grantee=perms/grantor and grantee may be an user in the form of username or group in the form of group groupname and matches against each table in a target schema

If a group exists with the same name as an user, the code above can break the following ways:

  1. The code may match the grantor portion of an ACL entry and fail to pick up any permissions
  2. It may pick up grants to an user rather than the group, depending on the order in which the ACL entries occur.
  3. If a schema has 10 tables and the user has SELECT granted to only one of these, that may be interpreted by the code as having SELECT granted on all tables in the schema (I haven't verified this)
  4. Related to the the above, the code may pick up grants created by redshift_default_privileges if a table was added to the schema, even if no redshift_grants resources were applied before.
  5. I don't understand how schema grants are verified (if at all) when there are no tables in a schema and the above query returns zero rows.

Depending on the nature of the error this may result in an one-off diff or even a permanent diff, usually when tables are created outside of Terraform, especially if the creating user had some default permissions that would apply grants to a newly created table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions