Skip to content

Commit 651250e

Browse files
wip
1 parent 45bdd0a commit 651250e

File tree

6 files changed

+353
-1
lines changed

6 files changed

+353
-1
lines changed

MIGRATION_GUIDE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ No changes in configuration are required.
5858

5959
Community PR: [#4185](https://github.com/snowflakedb/terraform-provider-snowflake/pull/4185)
6060

61+
### *(new feature)* snowflake_listings datasource
62+
Added a new preview data source for listings. See reference [docs](https://docs.snowflake.com/en/sql-reference/sql/show-listings).
63+
64+
This data source focuses on base query commands (SHOW LISTINGS and DESCRIBE LISTING). Other query commands like SHOW AVAILABLE LISTINGS, DESCRIBE AVAILABLE LISTING, SHOW LISTING OFFERS, SHOW OFFERS, SHOW PRICING PLANS, and SHOW VERSIONS IN LISTING are not included and will be added depending on demand.
65+
66+
This feature will be marked as a stable feature in future releases. Breaking changes are expected, even without bumping the major version. To use this feature, add `snowflake_listings_datasource` to `preview_features_enabled` field in the provider configuration.
67+
6168
## v2.10.0 ➞ v2.10.1
6269

6370
### *(bugfix)* Fixed parsing DESCRIBE output for authentication policies

docs/data-sources/listings.md

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
---
2+
page_title: "snowflake_listings Data Source - terraform-provider-snowflake"
3+
subcategory: "Preview"
4+
description: |-
5+
Data source used to get details of filtered listings. Filtering is aligned with the current possibilities for SHOW LISTINGS query (like, starts_with, and limit are supported). The results of SHOW and DESCRIBE are encapsulated in one output collection.
6+
---
7+
8+
!> **Preview Feature** This data source is a preview feature and is subject to breaking changes, even without bumping the major version. To use this feature, add `snowflake_listings_datasource` to `preview_features_enabled` field in the provider configuration. Read more about preview features in our [documentation](../#preview-features).
9+
10+
-> **Note** This data source focuses on base query commands (SHOW LISTINGS and DESCRIBE LISTING). Other query commands like SHOW AVAILABLE LISTINGS, DESCRIBE AVAILABLE LISTING, SHOW LISTING OFFERS, SHOW OFFERS, SHOW PRICING PLANS, and SHOW VERSIONS IN LISTING are not included and will be added depending on demand.
11+
12+
# snowflake_listings (Data Source)
13+
14+
Data source used to get details of filtered listings. Filtering is aligned with the current possibilities for SHOW LISTINGS query (`like`, `starts_with`, and `limit` are supported). The results of SHOW and DESCRIBE are encapsulated in one output collection.
15+
16+
## Example Usage
17+
18+
```terraform
19+
# Simple usage
20+
data "snowflake_listings" "simple" {
21+
}
22+
23+
output "simple_output" {
24+
value = data.snowflake_listings.simple.listings
25+
}
26+
27+
# Filtering (like)
28+
data "snowflake_listings" "like" {
29+
like = "listing-name"
30+
}
31+
32+
output "like_output" {
33+
value = data.snowflake_listings.like.listings
34+
}
35+
36+
# Filtering by prefix (like)
37+
data "snowflake_listings" "like_prefix" {
38+
like = "prefix%"
39+
}
40+
41+
output "like_prefix_output" {
42+
value = data.snowflake_listings.like_prefix.listings
43+
}
44+
45+
# Filtering (starts_with)
46+
data "snowflake_listings" "starts_with" {
47+
starts_with = "prefix-"
48+
}
49+
50+
output "starts_with_output" {
51+
value = data.snowflake_listings.starts_with.listings
52+
}
53+
54+
# Filtering (limit)
55+
data "snowflake_listings" "limit" {
56+
limit {
57+
rows = 10
58+
from = "prefix-"
59+
}
60+
}
61+
62+
output "limit_output" {
63+
value = data.snowflake_listings.limit.listings
64+
}
65+
66+
# Without additional data (to limit the number of calls make for every found listing)
67+
data "snowflake_listings" "only_show" {
68+
# with_describe is turned on by default and it calls DESCRIBE LISTING for every listing found and attaches its output to listings.*.describe_output field
69+
with_describe = false
70+
}
71+
72+
output "only_show_output" {
73+
value = data.snowflake_listings.only_show.listings
74+
}
75+
76+
# Ensure the number of listings is equal to at least one element (with the use of postcondition)
77+
data "snowflake_listings" "assert_with_postcondition" {
78+
like = "listing-name%"
79+
lifecycle {
80+
postcondition {
81+
condition = length(self.listings) > 0
82+
error_message = "there should be at least one listing"
83+
}
84+
}
85+
}
86+
87+
# Ensure the number of listings is equal to exactly one element (with the use of check block)
88+
check "listing_check" {
89+
data "snowflake_listings" "assert_with_check_block" {
90+
like = "listing-name"
91+
}
92+
93+
assert {
94+
condition = length(data.snowflake_listings.assert_with_check_block.listings) == 1
95+
error_message = "listings filtered by '${data.snowflake_listings.assert_with_check_block.like}' returned ${length(data.snowflake_listings.assert_with_check_block.listings)} listings where one was expected"
96+
}
97+
}
98+
```
99+
100+
-> **Note** If a field has a default value, it is shown next to the type in the schema.
101+
102+
<!-- schema generated by tfplugindocs -->
103+
## Schema
104+
105+
### Optional
106+
107+
- `like` (String) Filters the output with **case-insensitive** pattern, with support for SQL wildcard characters (`%` and `_`).
108+
- `limit` (Block List, Max: 1) Limits the number of rows returned. If the `limit.from` is set, then the limit will start from the first element matched by the expression. The expression is only used to match with the first element, later on the elements are not matched by the prefix, but you can enforce a certain pattern with `starts_with` or `like`. (see [below for nested schema](#nestedblock--limit))
109+
- `starts_with` (String) Filters the output with **case-sensitive** characters indicating the beginning of the object name.
110+
- `with_describe` (Boolean) (Default: `true`) Runs DESC LISTING for each listing returned by SHOW LISTINGS. The output of describe is saved to the description field. By default this value is set to true.
111+
112+
### Read-Only
113+
114+
- `id` (String) The ID of this resource.
115+
- `listings` (List of Object) Holds the aggregated output of all listings details queries. (see [below for nested schema](#nestedatt--listings))
116+
117+
<a id="nestedblock--limit"></a>
118+
### Nested Schema for `limit`
119+
120+
Required:
121+
122+
- `rows` (Number) The maximum number of rows to return.
123+
124+
Optional:
125+
126+
- `from` (String) Specifies a **case-sensitive** pattern that is used to match object name. After the first match, the limit on the number of rows will be applied.
127+
128+
129+
<a id="nestedatt--listings"></a>
130+
### Nested Schema for `listings`
131+
132+
Read-Only:
133+
134+
- `describe_output` (List of Object) (see [below for nested schema](#nestedobjatt--listings--describe_output))
135+
- `show_output` (List of Object) (see [below for nested schema](#nestedobjatt--listings--show_output))
136+
137+
<a id="nestedobjatt--listings--describe_output"></a>
138+
### Nested Schema for `listings.describe_output`
139+
140+
Read-Only:
141+
142+
- `application_package` (String)
143+
- `approver_contact` (String)
144+
- `business_needs` (String)
145+
- `categories` (String)
146+
- `comment` (String)
147+
- `created_on` (String)
148+
- `customized_contact_info` (String)
149+
- `data_attributes` (String)
150+
- `data_dictionary` (String)
151+
- `data_preview` (String)
152+
- `description` (String)
153+
- `distribution` (String)
154+
- `global_name` (String)
155+
- `is_application` (Boolean)
156+
- `is_by_request` (Boolean)
157+
- `is_limited_trial` (Boolean)
158+
- `is_monetized` (Boolean)
159+
- `is_mountless_queryable` (Boolean)
160+
- `is_share` (Boolean)
161+
- `is_targeted` (Boolean)
162+
- `last_committed_version_alias` (String)
163+
- `last_committed_version_name` (String)
164+
- `last_committed_version_uri` (String)
165+
- `legacy_uniform_listing_locators` (String)
166+
- `limited_trial_plan` (String)
167+
- `listing_terms` (String)
168+
- `live_version_uri` (String)
169+
- `manifest_yaml` (String)
170+
- `monetization_display_order` (String)
171+
- `name` (String)
172+
- `organization_profile_name` (String)
173+
- `owner` (String)
174+
- `owner_role_type` (String)
175+
- `profile` (String)
176+
- `published_on` (String)
177+
- `published_version_alias` (String)
178+
- `published_version_name` (String)
179+
- `published_version_uri` (String)
180+
- `refresh_schedule` (String)
181+
- `refresh_type` (String)
182+
- `regions` (String)
183+
- `rejection_reason` (String)
184+
- `request_approval_type` (String)
185+
- `resources` (String)
186+
- `retried_on` (String)
187+
- `review_state` (String)
188+
- `revisions` (String)
189+
- `scheduled_drop_time` (String)
190+
- `share` (String)
191+
- `state` (String)
192+
- `subtitle` (String)
193+
- `support_contact` (String)
194+
- `target_accounts` (String)
195+
- `title` (String)
196+
- `trial_details` (String)
197+
- `uniform_listing_locator` (String)
198+
- `unpublished_by_admin_reasons` (String)
199+
- `updated_on` (String)
200+
- `usage_examples` (String)
201+
202+
203+
<a id="nestedobjatt--listings--show_output"></a>
204+
### Nested Schema for `listings.show_output`
205+
206+
Read-Only:
207+
208+
- `comment` (String)
209+
- `created_on` (String)
210+
- `detailed_target_accounts` (String)
211+
- `distribution` (String)
212+
- `global_name` (String)
213+
- `is_application` (Boolean)
214+
- `is_by_request` (Boolean)
215+
- `is_limited_trial` (Boolean)
216+
- `is_monetized` (Boolean)
217+
- `is_mountless_queryable` (Boolean)
218+
- `is_targeted` (Boolean)
219+
- `name` (String)
220+
- `organization_profile_name` (String)
221+
- `owner` (String)
222+
- `owner_role_type` (String)
223+
- `profile` (String)
224+
- `published_on` (String)
225+
- `regions` (String)
226+
- `rejected_on` (String)
227+
- `review_state` (String)
228+
- `state` (String)
229+
- `subtitle` (String)
230+
- `target_accounts` (String)
231+
- `title` (String)
232+
- `uniform_listing_locator` (String)
233+
- `updated_on` (String)
234+

docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ provider "snowflake" {
140140
- `passcode_in_password` (Boolean) False by default. Set to true if the MFA passcode is embedded to the configured password. Can also be sourced from the `SNOWFLAKE_PASSCODE_IN_PASSWORD` environment variable.
141141
- `password` (String, Sensitive) Password for user + password or [token](https://docs.snowflake.com/en/user-guide/programmatic-access-tokens#generating-a-programmatic-access-token) for [PAT auth](https://docs.snowflake.com/en/user-guide/programmatic-access-tokens). Cannot be used with `private_key` and `private_key_passphrase`. Can also be sourced from the `SNOWFLAKE_PASSWORD` environment variable.
142142
- `port` (Number) Specifies a custom port value used by the driver for privatelink connections. Can also be sourced from the `SNOWFLAKE_PORT` environment variable.
143-
- `preview_features_enabled` (Set of String) A list of preview features that are handled by the provider. See [preview features list](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/LIST_OF_PREVIEW_FEATURES_FOR_V1.md). Preview features may have breaking changes in future releases, even without raising the major version. This field can not be set with environmental variables. Preview features that can be enabled are: `snowflake_account_authentication_policy_attachment_resource` | `snowflake_account_password_policy_attachment_resource` | `snowflake_alert_resource` | `snowflake_alerts_datasource` | `snowflake_api_integration_resource` | `snowflake_authentication_policy_resource` | `snowflake_authentication_policies_datasource` | `snowflake_cortex_search_service_resource` | `snowflake_cortex_search_services_datasource` | `snowflake_current_account_resource` | `snowflake_current_account_datasource` | `snowflake_current_organization_account_resource` | `snowflake_database_datasource` | `snowflake_database_role_datasource` | `snowflake_dynamic_table_resource` | `snowflake_dynamic_tables_datasource` | `snowflake_external_function_resource` | `snowflake_external_functions_datasource` | `snowflake_external_table_resource` | `snowflake_external_tables_datasource` | `snowflake_external_volume_resource` | `snowflake_failover_group_resource` | `snowflake_failover_groups_datasource` | `snowflake_file_format_resource` | `snowflake_file_formats_datasource` | `snowflake_function_java_resource` | `snowflake_function_javascript_resource` | `snowflake_function_python_resource` | `snowflake_function_scala_resource` | `snowflake_function_sql_resource` | `snowflake_functions_datasource` | `snowflake_job_service_resource` | `snowflake_managed_account_resource` | `snowflake_materialized_view_resource` | `snowflake_materialized_views_datasource` | `snowflake_network_policy_attachment_resource` | `snowflake_network_rule_resource` | `snowflake_email_notification_integration_resource` | `snowflake_notification_integration_resource` | `snowflake_object_parameter_resource` | `snowflake_password_policy_resource` | `snowflake_pipe_resource` | `snowflake_pipes_datasource` | `snowflake_current_role_datasource` | `snowflake_sequence_resource` | `snowflake_sequences_datasource` | `snowflake_share_resource` | `snowflake_shares_datasource` | `snowflake_parameters_datasource` | `snowflake_procedure_java_resource` | `snowflake_procedure_javascript_resource` | `snowflake_procedure_python_resource` | `snowflake_procedure_scala_resource` | `snowflake_procedure_sql_resource` | `snowflake_procedures_datasource` | `snowflake_stage_resource` | `snowflake_stages_datasource` | `snowflake_storage_integration_resource` | `snowflake_storage_integrations_datasource` | `snowflake_system_generate_scim_access_token_datasource` | `snowflake_system_get_aws_sns_iam_policy_datasource` | `snowflake_system_get_privatelink_config_datasource` | `snowflake_system_get_snowflake_platform_info_datasource` | `snowflake_table_column_masking_policy_application_resource` | `snowflake_table_constraint_resource` | `snowflake_table_resource` | `snowflake_tables_datasource` | `snowflake_user_authentication_policy_attachment_resource` | `snowflake_user_public_keys_resource` | `snowflake_user_password_policy_attachment_resource`. Promoted features that are stable and are enabled by default are: `snowflake_compute_pool_resource` | `snowflake_compute_pools_datasource` | `snowflake_git_repository_resource` | `snowflake_git_repositories_datasource` | `snowflake_image_repository_resource` | `snowflake_image_repositories_datasource` | `snowflake_listing_resource` | `snowflake_service_resource` | `snowflake_services_datasource` | `snowflake_user_programmatic_access_token_resource` | `snowflake_user_programmatic_access_tokens_datasource`. Promoted features can be safely removed from this field. They will be removed in the next major version.
143+
- `preview_features_enabled` (Set of String) A list of preview features that are handled by the provider. See [preview features list](https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/LIST_OF_PREVIEW_FEATURES_FOR_V1.md). Preview features may have breaking changes in future releases, even without raising the major version. This field can not be set with environmental variables. Preview features that can be enabled are: `snowflake_account_authentication_policy_attachment_resource` | `snowflake_account_password_policy_attachment_resource` | `snowflake_alert_resource` | `snowflake_alerts_datasource` | `snowflake_api_integration_resource` | `snowflake_authentication_policy_resource` | `snowflake_authentication_policies_datasource` | `snowflake_cortex_search_service_resource` | `snowflake_cortex_search_services_datasource` | `snowflake_current_account_resource` | `snowflake_current_account_datasource` | `snowflake_current_organization_account_resource` | `snowflake_database_datasource` | `snowflake_database_role_datasource` | `snowflake_dynamic_table_resource` | `snowflake_dynamic_tables_datasource` | `snowflake_external_function_resource` | `snowflake_external_functions_datasource` | `snowflake_external_table_resource` | `snowflake_external_tables_datasource` | `snowflake_external_volume_resource` | `snowflake_failover_group_resource` | `snowflake_failover_groups_datasource` | `snowflake_file_format_resource` | `snowflake_file_formats_datasource` | `snowflake_function_java_resource` | `snowflake_function_javascript_resource` | `snowflake_function_python_resource` | `snowflake_function_scala_resource` | `snowflake_function_sql_resource` | `snowflake_functions_datasource` | `snowflake_job_service_resource` | `snowflake_listings_datasource` | `snowflake_managed_account_resource` | `snowflake_materialized_view_resource` | `snowflake_materialized_views_datasource` | `snowflake_network_policy_attachment_resource` | `snowflake_network_rule_resource` | `snowflake_email_notification_integration_resource` | `snowflake_notification_integration_resource` | `snowflake_object_parameter_resource` | `snowflake_password_policy_resource` | `snowflake_pipe_resource` | `snowflake_pipes_datasource` | `snowflake_current_role_datasource` | `snowflake_sequence_resource` | `snowflake_sequences_datasource` | `snowflake_share_resource` | `snowflake_shares_datasource` | `snowflake_parameters_datasource` | `snowflake_procedure_java_resource` | `snowflake_procedure_javascript_resource` | `snowflake_procedure_python_resource` | `snowflake_procedure_scala_resource` | `snowflake_procedure_sql_resource` | `snowflake_procedures_datasource` | `snowflake_stage_resource` | `snowflake_stages_datasource` | `snowflake_storage_integration_resource` | `snowflake_storage_integrations_datasource` | `snowflake_system_generate_scim_access_token_datasource` | `snowflake_system_get_aws_sns_iam_policy_datasource` | `snowflake_system_get_privatelink_config_datasource` | `snowflake_system_get_snowflake_platform_info_datasource` | `snowflake_table_column_masking_policy_application_resource` | `snowflake_table_constraint_resource` | `snowflake_table_resource` | `snowflake_tables_datasource` | `snowflake_user_authentication_policy_attachment_resource` | `snowflake_user_public_keys_resource` | `snowflake_user_password_policy_attachment_resource`. Promoted features that are stable and are enabled by default are: `snowflake_compute_pool_resource` | `snowflake_compute_pools_datasource` | `snowflake_git_repository_resource` | `snowflake_git_repositories_datasource` | `snowflake_image_repository_resource` | `snowflake_image_repositories_datasource` | `snowflake_listing_resource` | `snowflake_service_resource` | `snowflake_services_datasource` | `snowflake_user_programmatic_access_token_resource` | `snowflake_user_programmatic_access_tokens_datasource`. Promoted features can be safely removed from this field. They will be removed in the next major version.
144144
- `private_key` (String, Sensitive) Private Key for username+private-key auth. Cannot be used with `password`. Can also be sourced from the `SNOWFLAKE_PRIVATE_KEY` environment variable.
145145
- `private_key_passphrase` (String, Sensitive) Supports the encryption ciphers aes-128-cbc, aes-128-gcm, aes-192-cbc, aes-192-gcm, aes-256-cbc, aes-256-gcm, and des-ede3-cbc. Can also be sourced from the `SNOWFLAKE_PRIVATE_KEY_PASSPHRASE` environment variable.
146146
- `profile` (String) Sets the profile to read from ~/.snowflake/config file. Can also be sourced from the `SNOWFLAKE_PROFILE` environment variable.
@@ -767,6 +767,7 @@ To use them, add the relevant feature name to the `preview_features_enabled` fie
767767
- [snowflake_failover_groups](./docs/data-sources/failover_groups)
768768
- [snowflake_file_formats](./docs/data-sources/file_formats)
769769
- [snowflake_functions](./docs/data-sources/functions)
770+
- [snowflake_listings](./docs/data-sources/listings)
770771
- [snowflake_materialized_views](./docs/data-sources/materialized_views)
771772
- [snowflake_parameters](./docs/data-sources/parameters)
772773
- [snowflake_pipes](./docs/data-sources/pipes)

examples/additional/preview_data_sources.MD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- [snowflake_failover_groups](./docs/data-sources/failover_groups)
1515
- [snowflake_file_formats](./docs/data-sources/file_formats)
1616
- [snowflake_functions](./docs/data-sources/functions)
17+
- [snowflake_listings](./docs/data-sources/listings)
1718
- [snowflake_materialized_views](./docs/data-sources/materialized_views)
1819
- [snowflake_parameters](./docs/data-sources/parameters)
1920
- [snowflake_pipes](./docs/data-sources/pipes)

0 commit comments

Comments
 (0)