-
Notifications
You must be signed in to change notification settings - Fork 426
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: Add tags data source #3211
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
--- | ||
page_title: "snowflake_tags Data Source - terraform-provider-snowflake" | ||
subcategory: "" | ||
description: |- | ||
Datasource used to get details of filtered tags. Filtering is aligned with the current possibilities for SHOW TAGS https://docs.snowflake.com/en/sql-reference/sql/show-tags query. The results of SHOW are encapsulated in one output collection tags. | ||
--- | ||
|
||
!> **V1 release candidate** This data source is a release candidate for the V1. We do not expect significant changes in it before the V1. We will welcome any feedback and adjust the data source if needed. Any errors reported will be resolved with a higher priority. We encourage checking this data source out before the V1 release. Please follow the [migration guide](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/MIGRATION_GUIDE.md#v0980--v0990) to use it. | ||
|
||
# snowflake_tags (Data Source) | ||
|
||
Datasource used to get details of filtered tags. Filtering is aligned with the current possibilities for [SHOW TAGS](https://docs.snowflake.com/en/sql-reference/sql/show-tags) query. The results of SHOW are encapsulated in one output collection `tags`. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# Simple usage | ||
data "snowflake_tags" "simple" { | ||
} | ||
|
||
output "simple_output" { | ||
value = data.snowflake_tags.simple.tags | ||
} | ||
|
||
# Filtering (like) | ||
data "snowflake_tags" "like" { | ||
like = "tag-name" | ||
} | ||
|
||
output "like_output" { | ||
value = data.snowflake_tags.like.tags | ||
} | ||
|
||
# Filtering by prefix (like) | ||
data "snowflake_tags" "like_prefix" { | ||
like = "prefix%" | ||
} | ||
|
||
output "like_prefix_output" { | ||
value = data.snowflake_tags.like_prefix.tags | ||
} | ||
|
||
# Filtering (in) | ||
data "snowflake_tags" "in_account" { | ||
in { | ||
account = true | ||
} | ||
} | ||
|
||
data "snowflake_tags" "in_database" { | ||
in { | ||
database = "<database_name>" | ||
} | ||
} | ||
|
||
data "snowflake_tags" "in_schema" { | ||
in { | ||
schema = "<database_name>.<schema_name>" | ||
} | ||
} | ||
|
||
data "snowflake_tags" "in_application" { | ||
in { | ||
application = "<application_name>" | ||
} | ||
} | ||
|
||
data "snowflake_tags" "in_application_package" { | ||
in { | ||
application_package = "<application_package_name>" | ||
} | ||
} | ||
|
||
output "in_output" { | ||
value = { | ||
"account" : data.snowflake_tags.in_account.tags, | ||
"database" : data.snowflake_tags.in_database.tags, | ||
"schema" : data.snowflake_tags.in_schema.tags, | ||
"application" : data.snowflake_tags.in_application.tags, | ||
"application_package" : data.snowflake_tags.in_application_package.tags, | ||
} | ||
} | ||
|
||
output "in_output" { | ||
value = data.snowflake_tags.in.tags | ||
} | ||
|
||
# Ensure the number of tags is equal to at least one element (with the use of postcondition) | ||
data "snowflake_tags" "assert_with_postcondition" { | ||
like = "tag-name%" | ||
lifecycle { | ||
postcondition { | ||
condition = length(self.tags) > 0 | ||
error_message = "there should be at least one tag" | ||
} | ||
} | ||
} | ||
|
||
# Ensure the number of tags is equal to at exactly one element (with the use of check block) | ||
check "tag_check" { | ||
data "snowflake_tags" "assert_with_check_block" { | ||
like = "tag-name" | ||
} | ||
|
||
assert { | ||
condition = length(data.snowflake_tags.assert_with_check_block.tags) == 1 | ||
error_message = "tags filtered by '${data.snowflake_tags.assert_with_check_block.like}' returned ${length(data.snowflake_tags.assert_with_check_block.tags)} tags where one was expected" | ||
} | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Optional | ||
|
||
- `in` (Block List, Max: 1) IN clause to filter the list of objects (see [below for nested schema](#nestedblock--in)) | ||
- `like` (String) Filters the output with **case-insensitive** pattern, with support for SQL wildcard characters (`%` and `_`). | ||
|
||
### Read-Only | ||
|
||
- `id` (String) The ID of this resource. | ||
- `tags` (List of Object) Holds the aggregated output of all tags details queries. (see [below for nested schema](#nestedatt--tags)) | ||
|
||
<a id="nestedblock--in"></a> | ||
### Nested Schema for `in` | ||
|
||
Optional: | ||
|
||
- `account` (Boolean) Returns records for the entire account. | ||
- `application` (String) Returns records for the specified application. | ||
- `application_package` (String) Returns records for the specified application package. | ||
- `database` (String) Returns records for the current database in use or for a specified database. | ||
- `schema` (String) Returns records for the current schema in use or a specified schema. Use fully qualified name. | ||
|
||
|
||
<a id="nestedatt--tags"></a> | ||
### Nested Schema for `tags` | ||
|
||
Read-Only: | ||
|
||
- `show_output` (List of Object) (see [below for nested schema](#nestedobjatt--tags--show_output)) | ||
|
||
<a id="nestedobjatt--tags--show_output"></a> | ||
### Nested Schema for `tags.show_output` | ||
|
||
Read-Only: | ||
|
||
- `allowed_values` (Set of String) | ||
- `comment` (String) | ||
- `created_on` (String) | ||
- `database_name` (String) | ||
- `name` (String) | ||
- `owner` (String) | ||
- `owner_role_type` (String) | ||
- `schema_name` (String) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we recently agreed (in my pr) that we should write "data source" instead of "datasource"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I'll fix this in a follow up.