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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: grants datasource #1377

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 158 additions & 0 deletions docs/data-sources/grants.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "snowflake_grants Data Source - terraform-provider-snowflake"
subcategory: ""
description: |-

---

# snowflake_grants (Data Source)



## Example Usage

```terraform
# list all grants on account
data "snowflake_grants" "grants" {
grants_on {
account = true
}
}

# list all grants in database with name "tst"
data "snowflake_grants" "grants2" {
grants_on {
object_name = "\"tst\""
object_type = "DATABASE"
}
}

# list all grants to role with name "ACCOUNTADMIN"
data "snowflake_grants" "grants3" {
grants_to {
role = "ACCOUNTADMIN"
}
}

# list all grants of role with name "ACCOUNTADMIN"
data "snowflake_grants" "grants4" {
grants_of {
role = "ACCOUNTADMIN"
}
}

# list all grants in database with name "tst"
data "snowflake_grants" "grants5" {
future_grants_in {
database = "\"tst\""
}
}

# list all future grants in schema with name "mydatabase" and database with name "myschema"
data "snowflake_grants" "grants6" {
future_grants_in {
schema {
database_name = "\"mydatabase\""
schema_name = "\"myschema\""
}
}
}

# list all future grants to role with name "ACCOUNTADMIN"
data "snowflake_grants" "grants7" {
future_grants_to {
role = "ACCOUNTADMIN"
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `future_grants_in` (Block List, Max: 1) Lists all privileges on new (i.e. future) objects (see [below for nested schema](#nestedblock--future_grants_in))
- `future_grants_to` (Block List, Max: 1) Lists all privileges granted to the object on new (i.e. future) objects (see [below for nested schema](#nestedblock--future_grants_to))
- `grants_of` (Block List, Max: 1) Lists all objects to which the given object has been granted (see [below for nested schema](#nestedblock--grants_of))
- `grants_on` (Block List, Max: 1) Lists all privileges that have been granted on an object or account (see [below for nested schema](#nestedblock--grants_on))
- `grants_to` (Block List, Max: 1) Lists all privileges granted to the object (see [below for nested schema](#nestedblock--grants_to))

### Read-Only

- `grants` (List of Object) The list of grants (see [below for nested schema](#nestedatt--grants))
- `id` (String) The ID of this resource.

<a id="nestedblock--future_grants_in"></a>
### Nested Schema for `future_grants_in`

Optional:

- `database` (String) Lists all privileges on new (i.e. future) objects of a specified type in the database granted to a role.
- `schema` (Block List, Max: 1) Lists all privileges on new (i.e. future) objects of a specified type in the schema granted to a role. (see [below for nested schema](#nestedblock--future_grants_in--schema))

<a id="nestedblock--future_grants_in--schema"></a>
### Nested Schema for `future_grants_in.schema`

Required:

- `schema_name` (String) The name of the schema to list all privileges of new (ie. future) objects granted to

Optional:

- `database_name` (String) The database in which the scehma resides. Optional when querying a schema in the current database.



<a id="nestedblock--future_grants_to"></a>
### Nested Schema for `future_grants_to`

Required:

- `role` (String) Lists all privileges on new (i.e. future) objects of a specified type in a database or schema granted to the role.


<a id="nestedblock--grants_of"></a>
### Nested Schema for `grants_of`

Optional:

- `role` (String) Lists all users and roles to which the role has been granted
- `share` (String) Lists all the accounts for the share and indicates the accounts that are using the share.


<a id="nestedblock--grants_on"></a>
### Nested Schema for `grants_on`

Optional:

- `account` (Boolean) Object hierarchy to list privileges on. The only valid value is: ACCOUNT. Setting this attribute lists all the account-level (i.e. global) privileges that have been granted to roles.
- `object_name` (String) Name of object to list privileges on
- `object_type` (String) Type of object to list privileges on.


<a id="nestedblock--grants_to"></a>
### Nested Schema for `grants_to`

Optional:

- `role` (String) Lists all privileges and roles granted to the role
- `share` (String) Lists all the privileges granted to the share
- `user` (String) Lists all the roles granted to the user. Note that the PUBLIC role, which is automatically available to every user, is not listed


<a id="nestedatt--grants"></a>
### Nested Schema for `grants`

Read-Only:

- `created_on` (String)
- `grant_option` (Boolean)
- `granted_by` (String)
- `granted_on` (String)
- `granted_to` (String)
- `grantee_name` (String)
- `name` (String)
- `privilege` (String)


52 changes: 52 additions & 0 deletions examples/data-sources/snowflake_grants/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# list all grants on account
data "snowflake_grants" "grants" {
grants_on {
account = true
}
}

# list all grants in database with name "tst"
data "snowflake_grants" "grants2" {
grants_on {
object_name = "\"tst\""
object_type = "DATABASE"
}
}

# list all grants to role with name "ACCOUNTADMIN"
data "snowflake_grants" "grants3" {
grants_to {
role = "ACCOUNTADMIN"
}
}

# list all grants of role with name "ACCOUNTADMIN"
data "snowflake_grants" "grants4" {
grants_of {
role = "ACCOUNTADMIN"
}
}

# list all grants in database with name "tst"
data "snowflake_grants" "grants5" {
future_grants_in {
database = "\"tst\""
}
}

# list all future grants in schema with name "mydatabase" and database with name "myschema"
data "snowflake_grants" "grants6" {
future_grants_in {
schema {
database_name = "\"mydatabase\""
schema_name = "\"myschema\""
}
}
}

# list all future grants to role with name "ACCOUNTADMIN"
data "snowflake_grants" "grants7" {
future_grants_to {
role = "ACCOUNTADMIN"
}
}
Loading