-
Notifications
You must be signed in to change notification settings - Fork 427
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
feat: create snowflake_role_ownership_grant resource #917
Conversation
…ecause terraform would lose ownership of the role.
@alldoami I think this is ready for peer review. |
If we wanted to use this |
@alldoami I considered adding multiple types but that implementation is very nuanced so I opted to only support on role ownership initially since that is what the #460 called for. That being said, I wrote this resource so that it could be expanded to support multiple ON object types in the future if that made sense. Do you want a single resource handling resource "snowflake_ownership_grant" "role" {
type = "ROLE"
name = snowflake_role.role.name
role_name = snowflake_role.other_role.name
}
resource "snowflake_ownership_grant" "user" {
type = "USER"
name = snowflake_user.user.name
role_name = snowflake_role.other_role.name
} However, we won't get much mileage out of the added complexity of this "generic" resource implementation because it would only support resource "snowflake_ownership_grant" "warehouse" {
type = "WAREHOUSE"
name = "wh"
role_name = "role1"
} would be redundant to the existing resource "snowflake_warehouse_grant" "grant" {
warehouse_name = "wh"
privilege = "OWNERSHIP"
roles = [
"role1",
]
} Given the considerations above, I think it is best to have two special resources. The # GRANT OWNERSHIP ON ROLE "role" TO ROLE "role1" COPY CURRENT GRANTS
resource "snowflake_role_ownership_grant" "grant" {
on_role_name = "role"
to_role_name = "role1",
current_grants = "COPY"
}
# not to be confused with the existing `snowflake_role_grants` resource which handles `GRANT ROLE` and a # GRANT OWNERSHIP ON USER "user" TO ROLE "role1" COPY CURRENT GRANTS
resource "snowflake_user_ownership_grant" "grant" {
on_user_name = "user"
to_role_name = "role1",
current_grants = "COPY"
} Both special resources could share the common |
Got it @aidanmelen, this makes sense. Thank you for contributing! |
/ok-to-test sha=5c1de73 |
Integration tests success for 5c1de73 |
can you run |
I keep trying to add an example to the docs after it generates, but the |
@alldoami docs should be passing now |
That was fun! Thanks for considering my contribution! |
I will plan on making another PR for the |
/ok-to-test sha=04b1260 |
Integration tests success for 04b1260 |
@aidanmelen GHA broke today and I think we need to rekick off the GHA jobs, do you think you can commit an empty commit to your branch? |
@alldoami done |
/ok-to-test sha=d734035 |
Integration tests success for d734035 |
/ok-to-test sha=274b54b |
Integration tests failure for 274b54b |
/ok-to-test sha=65f7a5b |
Integration tests success for 65f7a5b |
Create a
snowflake_role_ownership_grant
resource.Test Plan
to_role
after creation, the ownership changed back toACCOUNTADMIN
. the following apply rebuilt the role and re-granted role ownership.References
Example
I created a new example under
examples/resources/snowflake_role_ownership_grant
resulting role ownership: