Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tag-association-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jmichalak committed Nov 28, 2024
2 parents 818d00b + c209a8a commit 7751436
Show file tree
Hide file tree
Showing 260 changed files with 13,836 additions and 3,380 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ jobs:
go-version-file: ./go.mod
cache: false

- name: Apply masking
run: |
while IFS= read -r line || [[ -n $line ]]; do
echo "::add-mask::$line"
done < <(printf '%s' "$SF_TF_GH_MASKING")
env:
SF_TF_GH_MASKING: ${{ secrets.SF_TF_GH_MASKING }}

- name: Install dependencies
run: make dev-setup

Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## [0.99.0](https://github.com/Snowflake-Labs/terraform-provider-snowflake/compare/v0.98.0...v0.99.0) (2024-11-26)


### 🎉 **What's new:**

* Add tags data source ([#3211](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3211)) ([8907d9d](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/8907d9dfea69d6b8ac26fc0a9e249676f332f8b3))
* Tag resource v1 ([#3197](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3197)) ([77b3bf0](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/77b3bf0c9998c05a30951730439f8b03a2e418ac))
* Tasks v1 readiness ([#3222](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3222)) ([e2284d9](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/e2284d98d23586031514934d7bc7c67139f5e272))


### 🔧 **Misc**

* Add support for usage tracking to data sources ([#3224](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3224)) ([8210bb8](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/8210bb84b69fe91e0fff22ac836feb79d6e9a402))
* Add usage tracking for the rest of the resources and fix views ([#3223](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3223)) ([231f653](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/231f65323611f110564117a325062355e7ed7cf6))
* Basic object tracking ([#3205](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3205)) ([1f0dc94](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/1f0dc94e6ac95940ac5fd0e0b5f62152b8f821a5))
* basic object tracking part 2 ([#3214](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3214)) ([e44f2e1](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/e44f2e1938807285ed4d521b56d2efeab7b927bb))
* Improve tags integration tests ([#3193](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3193)) ([7736e0a](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/7736e0a5fa6a97f9e5551507cea955fb62dd1e90))
* parser and secret tests ([#3192](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3192)) ([5ec9c86](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/5ec9c86fdc3450f6f07820a4a5fe7f74779c7c41))
* Storage integration with custom protocol ([#3213](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3213)) ([a3a44ae](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/a3a44ae5a6eca2a9623369499d8cac4516a87004))
* Unskip auth config tests ([#3180](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3180)) ([46ab142](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/46ab142ad74e5fdc5deb6cc6edc409f487434862))


### 🐛 **Bug fixes:**

* Small fixes and adjustments ([#3226](https://github.com/Snowflake-Labs/terraform-provider-snowflake/issues/3226)) ([9f67457](https://github.com/Snowflake-Labs/terraform-provider-snowflake/commit/9f6745743daba831422627b5171df404373e9650))

## [0.98.0](https://github.com/Snowflake-Labs/terraform-provider-snowflake/compare/v0.97.0...v0.98.0) (2024-11-08)


Expand Down
152 changes: 151 additions & 1 deletion MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ across different versions.
> [!TIP]
> We highly recommend upgrading the versions one by one instead of bulk upgrades.
## v0.98.0 ➞ v0.99.0
## v0.99.0 ➞ v0.100.0

### snowflake_tag_association resource changes
#### *(behavior change)* new id format
Expand Down Expand Up @@ -64,6 +64,156 @@ resource "snowflake_tag_association" "table_association" {

The state is migrated automatically. Please adjust your configuration files.

## v0.98.0 ➞ v0.99.0

### snowflake_tasks data source changes

New filtering options:
- `with_parameters`
- `like`
- `in`
- `starts_with`
- `root_only`
- `limit`

New output fields
- `show_output`
- `parameters`

Breaking changes:
- `database` and `schema` are right now under `in` field

Before:
```terraform
data "snowflake_tasks" "old_tasks" {
database = "<database_name>"
schema = "<schema_name>"
}
```
After:
```terraform
data "snowflake_tasks" "new_tasks" {
in {
# for IN SCHEMA specify:
schema = "<database_name>.<schema_name>"
# for IN DATABASE specify:
database = "<database_name>"
}
}
```
- `tasks` field now organizes output of show under `show_output` field and the output of show parameters under `parameters` field.

Before:
```terraform
output "simple_output" {
value = data.snowflake_tasks.test.tasks[0].name
}
```
After:
```terraform
output "simple_output" {
value = data.snowflake_tasks.test.tasks[0].show_output[0].name
}
```

### snowflake_task resource changes
New fields:
- `config` - enables to specify JSON-formatted metadata that can be retrieved in the `sql_statement` by using [SYSTEM$GET_TASK_GRAPH_CONFIG](https://docs.snowflake.com/en/sql-reference/functions/system_get_task_graph_config).
- `show_output` and `parameters` fields added for holding SHOW and SHOW PARAMETERS output (see [raw Snowflake output](./v1-preparations/CHANGES_BEFORE_V1.md#raw-snowflake-output)).
- Added support for finalizer tasks with `finalize` field. It conflicts with `after` and `schedule` (see [finalizer tasks](https://docs.snowflake.com/en/user-guide/tasks-graphs#release-and-cleanup-of-task-graphs)).

Changes:
- `enabled` field changed to `started` and type changed to string with only boolean values available (see ["empty" values](./v1-preparations/CHANGES_BEFORE_V1.md#empty-values)). It is also now required field, so make sure it's explicitly set (previously it was optional with the default value set to `false`).
- `allow_overlapping_execution` type was changed to string with only boolean values available (see ["empty" values](./v1-preparations/CHANGES_BEFORE_V1.md#empty-values)). Previously, it had the default set to `false` which will be migrated. If nothing will be set the provider will plan the change to `default` value. If you want to make sure it's turned off, set it explicitly to `false`.

Before:
```terraform
resource "snowflake_task" "example" {
# ...
enabled = true
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
started = true
# ...
}
```
- `schedule` field changed from single value to a nested object that allows for specifying either minutes or cron

Before:
```terraform
resource "snowflake_task" "example" {
# ...
schedule = "5 MINUTES"
# or
schedule = "USING CRON * * * * * UTC"
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
schedule {
minutes = 5
# or
using_cron = "* * * * * UTC"
}
# ...
}
```
- All task parameters defined in [the Snowflake documentation](https://docs.snowflake.com/en/sql-reference/parameters) added into the top-level schema and removed `session_parameters` map.

Before:
```terraform
resource "snowflake_task" "example" {
# ...
session_parameters = {
QUERY_TAG = "<query_tag>"
}
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
query_tag = "<query_tag>"
# ...
}
```

- `after` field type was changed from `list` to `set` and the values were changed from names to fully qualified names.

Before:
```terraform
resource "snowflake_task" "example" {
# ...
after = ["<task_name>", snowflake_task.some_task.name]
# ...
}
```
After:
```terraform
resource "snowflake_task" "example" {
# ...
after = ["<database_name>.<schema_name>.<task_name>", snowflake_task.some_task.fully_qualified_name]
# ...
}
```

### *(new feature)* snowflake_tags datasource
Added a new datasource enabling querying and filtering tags. Notes:
- all results are stored in `tags` field.
- `like` field enables tags filtering by name.
- `in` field enables tags filtering by `account`, `database`, `schema`, `application` and `application_package`.
- `SHOW TAGS` output is enclosed in `show_output` field inside `tags`.

### snowflake_tag_masking_policy_association deprecation
`snowflake_tag_masking_policy_association` is now deprecated in favor of `snowflake_tag` with a new `masking_policy` field. It will be removed with the v1 release. Please adjust your configuration files.

Expand Down
117 changes: 114 additions & 3 deletions docs/data-sources/streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,120 @@ Datasource used to get details of filtered streams. Filtering is aligned with th
## Example Usage

```terraform
data "snowflake_streams" "current" {
database = "MYDB"
schema = "MYSCHEMA"
# Simple usage
data "snowflake_streams" "simple" {
}
output "simple_output" {
value = data.snowflake_streams.simple.streams
}
# Filtering (like)
data "snowflake_streams" "like" {
like = "stream-name"
}
output "like_output" {
value = data.snowflake_streams.like.streams
}
# Filtering by prefix (like)
data "snowflake_streams" "like_prefix" {
like = "prefix%"
}
output "like_prefix_output" {
value = data.snowflake_streams.like_prefix.streams
}
# Filtering (limit)
data "snowflake_streams" "limit" {
limit {
rows = 10
from = "prefix-"
}
}
output "limit_output" {
value = data.snowflake_streams.limit.streams
}
# Filtering (in)
data "snowflake_streams" "in_account" {
in {
account = true
}
}
data "snowflake_streams" "in_database" {
in {
database = "<database_name>"
}
}
data "snowflake_streams" "in_schema" {
in {
schema = "<database_name>.<schema_name>"
}
}
data "snowflake_streams" "in_application" {
in {
application = "<application_name>"
}
}
data "snowflake_streams" "in_application_package" {
in {
application_package = "<application_package_name>"
}
}
output "in_output" {
value = {
"account" : data.snowflake_streams.in_account.streams,
"database" : data.snowflake_streams.in_database.streams,
"schema" : data.snowflake_streams.in_schema.streams,
"application" : data.snowflake_streams.in_application.streams,
"application_package" : data.snowflake_streams.in_application_package.streams,
}
}
output "in_output" {
value = data.snowflake_streams.in.streams
}
# Without additional data (to limit the number of calls make for every found stream)
data "snowflake_streams" "only_show" {
# with_describe is turned on by default and it calls DESCRIBE STREAM for every stream found and attaches its output to streams.*.describe_output field
with_describe = false
}
output "only_show_output" {
value = data.snowflake_streams.only_show.streams
}
# Ensure the number of streams is equal to at least one element (with the use of postcondition)
data "snowflake_streams" "assert_with_postcondition" {
like = "stream-name%"
lifecycle {
postcondition {
condition = length(self.streams) > 0
error_message = "there should be at least one stream"
}
}
}
# Ensure the number of streams is equal to at exactly one element (with the use of check block)
check "stream_check" {
data "snowflake_streams" "assert_with_check_block" {
like = "stream-name"
}
assert {
condition = length(data.snowflake_streams.assert_with_check_block.streams) == 1
error_message = "streams filtered by '${data.snowflake_streams.assert_with_check_block.like}' returned ${length(data.snowflake_streams.assert_with_check_block.streams)} streams where one was expected"
}
}
```

Expand Down
Loading

0 comments on commit 7751436

Please sign in to comment.