Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
7 changes: 7 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ for changes required after enabling given [Snowflake BCR Bundle](https://docs.sn

## v2.11.x ➞ v2.12.0

### *(new feature)* snowflake_listings datasource
Added a new preview data source for listings. See reference [docs](https://docs.snowflake.com/en/sql-reference/sql/show-listings).

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.

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.

### *(improvement)* snowflake_scim_integration now accepts custom role names for run_as_role

Previously, the `run_as_role` field in the [snowflake_scim_integration](https://registry.terraform.io/providers/snowflakedb/snowflake/2.11.0/docs/resources/scim_integration) resource only accepted predefined role names: `OKTA_PROVISIONER`, `AAD_PROVISIONER`, or `GENERIC_SCIM_PROVISIONER`.
Expand Down
234 changes: 234 additions & 0 deletions docs/data-sources/listings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
---
page_title: "snowflake_listings Data Source - terraform-provider-snowflake"
subcategory: "Preview"
description: |-
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.
---

!> **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).

-> **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.

# snowflake_listings (Data Source)

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.

## Example Usage

```terraform
# Simple usage
data "snowflake_listings" "simple" {
}

output "simple_output" {
value = data.snowflake_listings.simple.listings
}

# Filtering (like)
data "snowflake_listings" "like" {
like = "listing-name"
}

output "like_output" {
value = data.snowflake_listings.like.listings
}

# Filtering by prefix (like)
data "snowflake_listings" "like_prefix" {
like = "prefix%"
}

output "like_prefix_output" {
value = data.snowflake_listings.like_prefix.listings
}

# Filtering (starts_with)
data "snowflake_listings" "starts_with" {
starts_with = "prefix-"
}

output "starts_with_output" {
value = data.snowflake_listings.starts_with.listings
}

# Filtering (limit)
data "snowflake_listings" "limit" {
limit {
rows = 10
from = "prefix-"
}
}

output "limit_output" {
value = data.snowflake_listings.limit.listings
}

# Without additional data (to limit the number of calls make for every found listing)
data "snowflake_listings" "only_show" {
# 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
with_describe = false
}

output "only_show_output" {
value = data.snowflake_listings.only_show.listings
}

# Ensure the number of listings is equal to at least one element (with the use of postcondition)
data "snowflake_listings" "assert_with_postcondition" {
like = "listing-name%"
lifecycle {
postcondition {
condition = length(self.listings) > 0
error_message = "there should be at least one listing"
}
}
}

# Ensure the number of listings is equal to exactly one element (with the use of check block)
check "listing_check" {
data "snowflake_listings" "assert_with_check_block" {
like = "listing-name"
}

assert {
condition = length(data.snowflake_listings.assert_with_check_block.listings) == 1
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"
}
}
```

-> **Note** If a field has a default value, it is shown next to the type in the schema.

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

### Optional

- `like` (String) Filters the output with **case-insensitive** pattern, with support for SQL wildcard characters (`%` and `_`).
- `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))
- `starts_with` (String) Filters the output with **case-sensitive** characters indicating the beginning of the object name.
- `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.

### Read-Only

- `id` (String) The ID of this resource.
- `listings` (List of Object) Holds the aggregated output of all listings details queries. (see [below for nested schema](#nestedatt--listings))

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

Required:

- `rows` (Number) The maximum number of rows to return.

Optional:

- `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.


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

Read-Only:

- `describe_output` (List of Object) (see [below for nested schema](#nestedobjatt--listings--describe_output))
- `show_output` (List of Object) (see [below for nested schema](#nestedobjatt--listings--show_output))

<a id="nestedobjatt--listings--describe_output"></a>
### Nested Schema for `listings.describe_output`

Read-Only:

- `application_package` (String)
- `approver_contact` (String)
- `business_needs` (String)
- `categories` (String)
- `comment` (String)
- `created_on` (String)
- `customized_contact_info` (String)
- `data_attributes` (String)
- `data_dictionary` (String)
- `data_preview` (String)
- `description` (String)
- `distribution` (String)
- `global_name` (String)
- `is_application` (Boolean)
- `is_by_request` (Boolean)
- `is_limited_trial` (Boolean)
- `is_monetized` (Boolean)
- `is_mountless_queryable` (Boolean)
- `is_share` (Boolean)
- `is_targeted` (Boolean)
- `last_committed_version_alias` (String)
- `last_committed_version_name` (String)
- `last_committed_version_uri` (String)
- `legacy_uniform_listing_locators` (String)
- `limited_trial_plan` (String)
- `listing_terms` (String)
- `live_version_uri` (String)
- `manifest_yaml` (String)
- `monetization_display_order` (String)
- `name` (String)
- `organization_profile_name` (String)
- `owner` (String)
- `owner_role_type` (String)
- `profile` (String)
- `published_on` (String)
- `published_version_alias` (String)
- `published_version_name` (String)
- `published_version_uri` (String)
- `refresh_schedule` (String)
- `refresh_type` (String)
- `regions` (String)
- `rejection_reason` (String)
- `request_approval_type` (String)
- `resources` (String)
- `retried_on` (String)
- `review_state` (String)
- `revisions` (String)
- `scheduled_drop_time` (String)
- `share` (String)
- `state` (String)
- `subtitle` (String)
- `support_contact` (String)
- `target_accounts` (String)
- `title` (String)
- `trial_details` (String)
- `uniform_listing_locator` (String)
- `unpublished_by_admin_reasons` (String)
- `updated_on` (String)
- `usage_examples` (String)


<a id="nestedobjatt--listings--show_output"></a>
### Nested Schema for `listings.show_output`

Read-Only:

- `comment` (String)
- `created_on` (String)
- `detailed_target_accounts` (String)
- `distribution` (String)
- `global_name` (String)
- `is_application` (Boolean)
- `is_by_request` (Boolean)
- `is_limited_trial` (Boolean)
- `is_monetized` (Boolean)
- `is_mountless_queryable` (Boolean)
- `is_targeted` (Boolean)
- `name` (String)
- `organization_profile_name` (String)
- `owner` (String)
- `owner_role_type` (String)
- `profile` (String)
- `published_on` (String)
- `regions` (String)
- `rejected_on` (String)
- `review_state` (String)
- `state` (String)
- `subtitle` (String)
- `target_accounts` (String)
- `title` (String)
- `uniform_listing_locator` (String)
- `updated_on` (String)

3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ provider "snowflake" {
- `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.
- `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.
- `port` (Number) Specifies a custom port value used by the driver for privatelink connections. Can also be sourced from the `SNOWFLAKE_PORT` environment variable.
- `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_notebook_resource` | `snowflake_notebooks_datasource` | `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_semantic_view_resource` | `snowflake_semantic_views_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.
- `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_notebook_resource` | `snowflake_notebooks_datasource` | `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_semantic_view_resource` | `snowflake_semantic_views_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.
- `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.
- `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.
- `profile` (String) Sets the profile to read from ~/.snowflake/config file. Can also be sourced from the `SNOWFLAKE_PROFILE` environment variable.
Expand Down Expand Up @@ -790,6 +790,7 @@ To use them, add the relevant feature name to the `preview_features_enabled` fie
- [snowflake_failover_groups](./docs/data-sources/failover_groups)
- [snowflake_file_formats](./docs/data-sources/file_formats)
- [snowflake_functions](./docs/data-sources/functions)
- [snowflake_listings](./docs/data-sources/listings)
- [snowflake_materialized_views](./docs/data-sources/materialized_views)
- [snowflake_notebooks](./docs/data-sources/notebooks)
- [snowflake_parameters](./docs/data-sources/parameters)
Expand Down
1 change: 1 addition & 0 deletions examples/additional/preview_data_sources.MD
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [snowflake_failover_groups](./docs/data-sources/failover_groups)
- [snowflake_file_formats](./docs/data-sources/file_formats)
- [snowflake_functions](./docs/data-sources/functions)
- [snowflake_listings](./docs/data-sources/listings)
- [snowflake_materialized_views](./docs/data-sources/materialized_views)
- [snowflake_notebooks](./docs/data-sources/notebooks)
- [snowflake_parameters](./docs/data-sources/parameters)
Expand Down
Loading
Loading