crossplane-contrib / provider-sql

An SQL provider for @crossplane
https://crossplane.io
Apache License 2.0
104 stars 59 forks source link

Flexibility to grant permissions to use extensions #177

Open offzale opened 4 months ago

offzale commented 4 months ago

What problem are you facing?

I am trying to provision an extension and the permissions to use it to a role. However, I am not able to do so since the Grant resource is quite limited.

The equivalent SQL statements of what I am trying to achieve are the following.

CREATE EXTENSION postgres_fdw;
GRANT USAGE ON FOREIGN DATA WRAPPER postgres_fdw TO <role>;

The extension could be installed like this.

apiVersion: postgresql.sql.crossplane.io/v1alpha1
kind: Extension
metadata:
  name: postgres-fdw
spec:
  providerConfigRef:
    name: postgres
  forProvider:
    database: my_db
    schema: public
    extension: postgres_fdw
    version: "1.1"

However, the required GRANT cannot be translated to the current Grant spec. I tried setting the privileges to ["USAGE ON FOREIGN DATA WRAPPER postgres_fdw"], but it is not supported as it does not match the regex ^[A-Z]+$.

How could Crossplane help solve your problem?

Extend the Grant resource to support a broader set of GRANT statements.