Skip to content
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
6 changes: 6 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ We decided to remove the instrumentation around the [Go Snowflake driver](https:

These changes should not affect any existing workflows (unless you have custom logic based on the old logs output).

### Removal of additional debug logs for the `snowflake_grant_privileges_to_role` resource

The environment variable `SF_TF_ADDITIONAL_DEBUG_LOGGING` was used to turn on the additional logging in the `snowflake_grant_privileges_to_role` resource. The additional logger was later used in multiple other places. We are currently removing it completely; however, we plan to address the logging topic globally in the provider.

These changes should not affect any existing workflows (unless you have custom logic based on the additional logs output - `sf-tf-additional-debug` prefix).

## v1.0.3 ➞ v1.0.4

### Fixed external_function VARCHAR return_type
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ Some links that might help you:
If you would like to create a GitHub issue, please read our [guide](./CREATING_ISSUES.md) first.
It contains useful links, FAQ, and commonly known issues with solutions that may already solve your case.

## Additional debug logs for `snowflake_grant_privileges_to_role` resource
Set environment variable `SF_TF_ADDITIONAL_DEBUG_LOGGING` to a non-empty value. Additional logs will be visible with `sf-tf-additional-debug` prefix, e.g.:
```text
2023/12/08 12:58:22.497078 sf-tf-additional-debug [DEBUG] Creating new client from db
```

## Additional SQL Client configuration
The provider uses the underlying [gosnowflake](https://github.com/snowflakedb/gosnowflake) driver to send SQL commands to Snowflake.

Expand Down
23 changes: 0 additions & 23 deletions pkg/internal/logging/debug_helpers.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import (
"fmt"
"reflect"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -61,7 +58,6 @@ func ApiAuthenticationIntegrationWithAuthorizationCodeGrant() *schema.Resource {
}

func ImportApiAuthenticationWithAuthorizationCodeGrant(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting api auth integration with authorization code grant import")
client := meta.(*provider.Context).Client
id, err := sdk.ParseAccountObjectIdentifier(d.Id())
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import (
"fmt"
"reflect"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -54,7 +51,6 @@ func ApiAuthenticationIntegrationWithClientCredentials() *schema.Resource {
}

func ImportApiAuthenticationWithClientCredentials(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting api auth integration with client credentials import")
client := meta.(*provider.Context).Client
id, err := sdk.ParseAccountObjectIdentifier(d.Id())
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@ import (
"fmt"
"reflect"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"

"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -59,7 +56,6 @@ func ApiAuthenticationIntegrationWithJwtBearer() *schema.Resource {
}

func ImportApiAuthenticationWithJwtBearer(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting api auth integration with jwt bearer import")
client := meta.(*provider.Context).Client
id, err := sdk.ParseAccountObjectIdentifier(d.Id())
if err != nil {
Expand Down
8 changes: 2 additions & 6 deletions pkg/resources/authentication_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ import (
"fmt"
"reflect"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down Expand Up @@ -125,7 +122,6 @@ func AuthenticationPolicy() *schema.Resource {
}

func ImportAuthenticationPolicy(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting authentication policy import")
client := meta.(*provider.Context).Client

id, err := sdk.ParseSchemaObjectIdentifier(d.Id())
Expand Down
10 changes: 4 additions & 6 deletions pkg/resources/custom_diffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider/sdkv2enhancements"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
Expand Down Expand Up @@ -184,7 +183,7 @@ func ForceNewIfAllKeysAreNotSet(key string, keys ...string) schema.CustomizeDiff
func RecreateWhenUserTypeChangedExternally(userType sdk.UserType) schema.CustomizeDiffFunc {
return func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
if n := diff.Get("user_type"); n != nil {
logging.DebugLogger.Printf("[DEBUG] new external value for user type %s\n", n.(string))
log.Printf("[DEBUG] new external value for user type: %s\n", n.(string))
if acceptableUserTypes, ok := sdk.AcceptableUserTypes[userType]; ok && !slices.Contains(acceptableUserTypes, strings.ToUpper(n.(string))) {
// we have to set here a value instead of just SetNewComputed
// because with empty value (default snowflake behavior for type) ForceNew fails
Expand All @@ -199,7 +198,7 @@ func RecreateWhenUserTypeChangedExternally(userType sdk.UserType) schema.Customi
func RecreateWhenSecretTypeChangedExternally(secretType sdk.SecretType) schema.CustomizeDiffFunc {
return func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
if n := diff.Get("secret_type"); n != nil {
logging.DebugLogger.Printf("[DEBUG] new external value for secret type %s\n", n.(string))
log.Printf("[DEBUG] new external value for secret type: %s\n", n.(string))

diffSecretType, _ := sdk.ToSecretType(n.(string))
if acceptableSecretTypes, ok := sdk.AcceptableSecretTypes[secretType]; ok && !slices.Contains(acceptableSecretTypes, diffSecretType) {
Expand Down Expand Up @@ -237,7 +236,7 @@ func RecreateWhenStreamTypeChangedExternally(streamType sdk.StreamSourceType) sc
func RecreateWhenResourceTypeChangedExternally[T ~string](typeField string, wantType T, toType func(string) (T, error)) schema.CustomizeDiffFunc {
return func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
if n := diff.Get(typeField); n != nil {
logging.DebugLogger.Printf("[DEBUG] new external value for %s: %s\n", typeField, n.(string))
log.Printf("[DEBUG] new external value for %s\n", typeField)

gotTypeRaw := n.(string)
// if the type is empty, the state is empty - do not recreate
Expand Down Expand Up @@ -275,8 +274,7 @@ func RecreateWhenStreamIsStale() schema.CustomizeDiffFunc {
func RecreateWhenResourceBoolFieldChangedExternally(boolField string, wantValue bool) schema.CustomizeDiffFunc {
return func(_ context.Context, diff *schema.ResourceDiff, _ interface{}) error {
if n := diff.Get(boolField); n != nil {
logging.DebugLogger.Printf("[DEBUG] new external value for %v: %v, recreating the resource...\n", boolField, n.(bool))

log.Printf("[DEBUG] new external value for %v, recreating the resource...\n", boolField)
if n.(bool) != wantValue {
return errors.Join(diff.SetNew(boolField, wantValue), diff.ForceNew(boolField))
}
Expand Down
7 changes: 1 addition & 6 deletions pkg/resources/external_oauth_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ import (
"fmt"
"reflect"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/collections"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"

"github.com/hashicorp/go-cty/cty"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
Expand Down Expand Up @@ -196,7 +192,6 @@ func ExternalOauthIntegration() *schema.Resource {
}

func ImportExternalOauthIntegration(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting external oauth integration import")
client := meta.(*provider.Context).Client
id, err := sdk.ParseAccountObjectIdentifier(d.Id())
if err != nil {
Expand Down
7 changes: 2 additions & 5 deletions pkg/resources/external_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import (
"errors"
"fmt"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/previewfeatures"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
Expand Down Expand Up @@ -139,7 +137,6 @@ func ExternalVolume() *schema.Resource {
}

func ImportExternalVolume(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting external volume import")
client := meta.(*provider.Context).Client
id, err := sdk.ParseAccountObjectIdentifier(d.Id())
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/resources/function_commons.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"slices"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/helpers"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/schemas"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
Expand Down Expand Up @@ -513,7 +512,6 @@ func UpdateFunction(language string, readFunc func(ctx context.Context, d *schem
}

func ImportFunction(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Starting function import")
client := meta.(*provider.Context).Client
id, err := sdk.ParseSchemaObjectIdentifierWithArguments(d.Id())
if err != nil {
Expand Down
8 changes: 1 addition & 7 deletions pkg/resources/grant_ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import (
"log"
"strings"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"

"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/logging"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/internal/provider"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/provider/resources"
"github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/sdk"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
Expand Down Expand Up @@ -171,12 +169,10 @@ func GrantOwnership() *schema.Resource {

func ImportGrantOwnership() schema.StateContextFunc {
return func(ctx context.Context, d *schema.ResourceData, meta any) ([]*schema.ResourceData, error) {
logging.DebugLogger.Printf("[DEBUG] Entering import grant privileges to account role")
id, err := ParseGrantOwnershipId(d.Id())
if err != nil {
return nil, err
}
logging.DebugLogger.Printf("[DEBUG] Imported identifier: %s", id.String())

switch id.GrantOwnershipTargetRoleKind {
case ToAccountGrantOwnershipTargetRoleKind:
Expand Down Expand Up @@ -246,7 +242,6 @@ func CreateGrantOwnership(ctx context.Context, d *schema.ResourceData, meta any)
if err != nil {
return diag.FromErr(err)
}
logging.DebugLogger.Printf("[DEBUG] created identifier from schema: %s", id.String())

grantOn, err := getOwnershipGrantOn(d)
if err != nil {
Expand All @@ -273,7 +268,6 @@ func CreateGrantOwnership(ctx context.Context, d *schema.ResourceData, meta any)
}
}

logging.DebugLogger.Printf("[DEBUG] Setting identifier to %s", id.String())
d.SetId(id.String())

return ReadGrantOwnership(ctx, d, meta)
Expand Down
Loading