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

terraform import failing for privileges grant import #2308

Closed
ankitsr92 opened this issue Dec 28, 2023 · 4 comments
Closed

terraform import failing for privileges grant import #2308

ankitsr92 opened this issue Dec 28, 2023 · 4 comments
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior

Comments

@ankitsr92
Copy link

Terraform CLI and Provider Versions

1.1.5
Snowflake 0.82

Terraform Configuration

terraform import "test_role|MANAGE GRANTS,MONITOR USAGE|false|false|true|false|false|false|false|false||||false||false|"

Apart from this need a way to derive this information for existing roles created in Snowflake.
How to derive this out of snowflake for a given role. Do you guys have any guide or helper SQL?
# format is role_name (string) | privileges (comma-delimited string) | all_privileges (bool) |with_grant_option (bool) | on_account (bool) | on_account_object (bool) | on_schema (bool) | on_schema_object (bool) | all (bool) | future (bool) | object_type (string) | object_name (string) | object_type_plural (string) | in_schema (bool) | schema_name (string) | in_database (bool) | database_name (string)

Expected Behavior

Executed successfully

Actual Behavior

The import command expects two arguments.
Usage: terraform [global options] import [options] ADDR ID

Import existing infrastructure into your Terraform state.

This will find and import the specified resource into your Terraform
state, allowing existing infrastructure to come under Terraform
management without having to be initially created by Terraform.

The ADDR specified is the address to import the resource to. Please
see the documentation online for resource addresses. The ID is a
resource-specific ID to identify that resource being imported. Please
reference the documentation for the resource type you're importing to
determine the ID syntax to use. It typically matches directly to the ID
that the provider uses.

The current implementation of Terraform import can only import resources
into the state. It does not generate configuration. A future version of
Terraform will also generate configuration.

Because of this, prior to running terraform import it is necessary to write
a resource configuration block for the resource manually, to which the
imported object will be attached.

This command will not modify your infrastructure, but it will make
network requests to inspect parts of your infrastructure relevant to
the resource being imported.

Options:

-config=path Path to a directory of Terraform configuration files
to use to configure the provider. Defaults to pwd.
If no config files are present, they must be provided
via the input prompts or env vars.

-allow-missing-config Allow import when no resource configuration block exists.

-input=false Disable interactive input prompts.

-lock=false Don't hold a state lock during the operation. This is
dangerous if others might concurrently run commands
against the same workspace.

-lock-timeout=0s Duration to retry a state lock.

-no-color If specified, output won't contain any color.

-var 'foo=bar' Set a variable in the Terraform configuration. This
flag can be set multiple times. This is only useful
with the "-config" flag.

-var-file=foo Set variables in the Terraform configuration from
a file. If "terraform.tfvars" or any ".auto.tfvars"
files are present, they will be automatically loaded.

-ignore-remote-version A rare option used for the remote backend only. See
the remote backend documentation for more information.

-state, state-out, and -backup are legacy options supported for the local
backend only. For more information, see the local backend's documentation.

Steps to Reproduce

terraform import "test_role|MANAGE GRANTS,MONITOR USAGE|false|false|true|false|false|false|false|false||||false||false|"

How much impact is this issue causing?

High

Logs

No response

Additional Information

No response

@ankitsr92 ankitsr92 added the bug Used to mark issues with provider's incorrect behavior label Dec 28, 2023
@sfc-gh-jcieslak
Copy link
Collaborator

@ankitsr92
Hey 👋,
There's an issue in your tf import command - docs. Before the import string, you have to pass an address to the resource. Otherwise, Terraform doesn't know where the state should be imported.
e.g. in your case, you have to prepare a resource that will look similar to this one

resource "snowflake_grant_privileges_to_role" "test_role_grant" {
  role_name = "test_role_123"
  privileges = [ "MANAGE GRANTS", "MONITOR USAGE" ]
  on_account = true
}

Only then you can import the state by running

terraform import snowflake_grant_privileges_to_role.test_role_grant "test_role|MANAGE GRANTS,MONITOR USAGE|false|false|true|false|false|false|false|false||||false||false|"

as you can see the import command expects the address to the resource.

@sfc-gh-jcieslak sfc-gh-jcieslak self-assigned this Jan 2, 2024
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @ankitsr92
Did my answer fix your issue? Can we close it?

@sfc-gh-jcieslak
Copy link
Collaborator

@ankitsr92 could you provide any updates on your issue?

@sfc-gh-jcieslak
Copy link
Collaborator

sfc-gh-jcieslak commented Mar 6, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior
Projects
None yet
Development

No branches or pull requests

2 participants