Hello ,
Dbt version :1.2
We have 3 git branches
develop - pointing to GCP dev project
uat - pointing to GCP uat project
prod - pointing to GCP prod project.
If we use the Grant in models/schema.yml file as below , when the models gets executed in dev,uat and prod the required access will granted in all the 3 environments.
Yes, User should have view access to UAT environment only. The same user should not have access to dev and prod environment even if we ran the models in dev and prod.
OK I spent some time looking at the documentation today and I don’t think that’s currently supported with the grants out of the box, so you have a few options:
open an issue on the dbt core repo describing your use case, as it could be a future enhancement (you should do this no matter what)
consider creating a custom version of the macro that handles the grant logic. You can override almost all of dbt’s functionality (see Did you know? dbt ships with its own project!), so if you made a custom version of the grants macro you could make it do different things based on the target. Hand-wavy but an option to consider.
I’m going to mark your post as the solution - although it doesn’t work for your use case, it might be useful for other people who come across this in the future