Skip to content
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

fix: 0.55 fix #1465

Merged
merged 2 commits into from
Jan 10, 2023
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
71 changes: 17 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@ This is a terraform provider plugin for managing [Snowflake](https://www.snowfla

## Getting Help

If you need help, try the [discussions area](https://github.com/Snowflake-Labs/terraform-provider-snowflake/discussions) of this repo.
If you need help, try the [discussions area](https://github.com/Snowflake-Labs/terraform-provider-snowflake/discussions) of this repo.

**Note**: If you are an enterprise customer, please file a support ticket with your Snowflake account representative. We prioritize support tickets over GitHub issues. Also it helps us with allocating additional engineering resources to supporting the provider.

## Install

The easiest way is to run this command:
You can install the provider using `terraform init`, all you need to do is include the following block in your Terraform settings configuration. Refer to [Explicit Provider Source Locations](https://www.terraform.io/upgrade-guides/0-13.html#explicit-provider-source-locations) for more information.

```shell
curl https://raw.githubusercontent.com/chanzuckerberg/terraform-provider-snowflake/main/download.sh | bash -s -- -b $HOME/.terraform.d/plugins
```hcl
terraform {
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "~> 0.55.0"
}
}
}
```

**Note that this will only work with recent releases, for older releases, use the version of download.sh that corresponds to that release (replace main in that curl with the version).**

It runs a script generated by [godownloader](https://github.com/goreleaser/godownloader) which installs into the proper directory for terraform (~/.terraform.d/plugins).

You can also just download a binary from our [releases](https://github.com/Snowflake-Labs/terraform-provider-snowflake/releases) and follow the [Terraform directions for installing 3rd party plugins](https://www.terraform.io/docs/configuration/providers.html#third-party-plugins).

### Upgrading from CZI Provider
As of (5/25/2022) to provider has been transferred from CZI to Snowflake-Labs. To upgrade from CZI, please run the following command:
As of (5/25/2022) to provider has been transferred from Chan Zuckerberg Initiative (CZI) to Snowflake-Labs. To upgrade from CZI, please run the following command:

```shell
terraform state replace-provider chanzuckerberg/snowflake Snowflake-Labs/snowflake
Expand All @@ -38,8 +41,6 @@ You should also update your lock file / Terraform provider version pinning. From
```hcl
# deprecated source
terraform {
required_version = ">= 1.1.7"

required_providers {
snowflake = {
source = "chanzuckerberg/snowflake"
Expand All @@ -54,8 +55,6 @@ To new source:
```hcl
# new source
terraform {
required_version = ">= 1.1.7"

required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
Expand All @@ -64,31 +63,13 @@ terraform {
}
}
```

If you are not pinning your provider versions, you may find it useful to forcefully upgrade providers using the command:
```
terraform init -upgrade
```

>**Note**: 0.34 is the first version published after the transfer. When the provider was transferred over not all releases were transferred for some reason. Only versions 0.28 and newer were transferred.

### For Terraform v0.13+ users

> We are now (7/29/2021) using Terraform 0.13 for testing purposes due to an issue for data sources for versions <0.13. Related PR for this change [here](https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/622#issuecomment-888879621).

You can use [Explicit Provider Source Locations](https://www.terraform.io/upgrade-guides/0-13.html#explicit-provider-source-locations).

The following should be used for provider locking:

```terraform
terraform {
required_providers {
snowflake = {
source = "Snowflake-Labs/snowflake"
version = "0.54.0"
}
}
}
```
>**Note**: 0.34 is the first version published after the transfer. When the provider was transferred over not all of the older releases were transferred for some reason. Only versions 0.28 and newer were transferred. If you are using a version older than 0.28, it is highly recommended to upgrade to a newer version.

## Usage

Expand Down Expand Up @@ -171,26 +152,8 @@ You will also need to generate a Github API token and add the secret:

**Note: releases can only be done by those with keybase pgp keys allowed in the terraform registry.**

Releases will be performed once a week on **Monday around 11am PST**. If your change is more urgent and you need to use it sooner, use the commit hash.
Releases will be performed as needed, typically once every 1-2 weeks. If your change is more urgent and you need to use it sooner, use the commit hash.

Releases are done by [goreleaser](https://goreleaser.com/) and run by our make files. There two goreleaser configs, `.goreleaser.yml` for regular releases and `.goreleaser.prerelease.yml` for doing prereleases (for testing).

Releases are [published to the terraform registry](https://registry.terraform.io/providers/chanzuckerberg/snowflake/latest), which requires that releases by signed.

## Adding a new releaser

To set up a new person for releasing, there are a few steps–

1. releaser: a [keybase account](https://keybase.io/) and a workstation set up with their [Keybase app](https://keybase.io/download).
2. releaser: a pgp key - `keybase pgp gen`
3. releaser: export public key.
1. If you have a single key in keybase–
1. `keybase pgp export`
2. If you have more than one key–
1. `keybase pgp export` to find id if key you want to export
2. `keybase pgp export -q KEY_ID`
4. github admin for chanzuckerberg: take public key exported above and add it [in the registry](https://registry.terraform.io/settings/gpg-keys)
5. releaser: set `KEYBASE_KEY_ID` environment variable. Note that this is different from the previous id. Get this one from `keybase pgp list`. It should be like ~70 characters long.
6. set `GITHUB_TOKEN` environment variable with a personal access token
7. releaser: run `make release-prerelease` to test that releases are working correctly
8. releaser: run `make release` to release for real
8 changes: 4 additions & 4 deletions pkg/resources/pipe_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,25 @@ func CreatePipeGrant(d *schema.ResourceData, meta interface{}) error {
pipeName string
schemaName string
)

if name, ok := d.GetOk("pipe_name"); ok {
pipeName = name.(string)
}
if name, ok := d.GetOk("schema_name"); ok {
schemaName = name.(string)
} else {
schemaName = ""
}

dbName := d.Get("database_name").(string)
priv := d.Get("privilege").(string)
onFuture := d.Get("on_future").(bool)
grantOption := d.Get("with_grant_option").(bool)
roles := expandStringList(d.Get("roles").(*schema.Set).List())

if (schemaName == "") && !onFuture {
return errors.New("schema_name must be set unless on_future is true.")
return errors.New("schema_name must be set unless on_future is true")
}
if (pipeName == "") && !onFuture {
return errors.New("pipe_name must be set unless on_future is true.")
return errors.New("pipe_name must be set unless on_future is true")
}

var builder snowflake.GrantBuilder
Expand Down