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

import of role_ownership_grant fails #2198

Closed
bert-ciandt opened this issue Nov 16, 2023 · 7 comments · Fixed by #2203
Closed

import of role_ownership_grant fails #2198

bert-ciandt opened this issue Nov 16, 2023 · 7 comments · Fixed by #2203
Assignees
Labels
bug Used to mark issues with provider's incorrect behavior category:grants

Comments

@bert-ciandt
Copy link

bert-ciandt commented Nov 16, 2023

Provider Version

0.75.0, 0.76.0 both have the problem

Terraform Version

1.6.3, 1.6.4 both have the problem

Describe the bug

When attempting to import a role_ownership_grant, I get an error:

`│ Error: Plugin did not respond

│ The plugin encountered an error, and failed to respond to the plugin6.(*GRPCProvider).ReadResource call. The plugin logs may contain more details.

Stack trace from the terraform-provider-snowflake_v0.76.0 plugin:

panic: runtime error: index out of range [2] with length 1

goroutine 288 [running]:
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources.ReadRoleOwnershipGrant(0xc000137700, {0x1ced480?, 0xc00076e5b0})
github.com/Snowflake-Labs/terraform-provider-snowflake/pkg/resources/role_ownership_grant.go:90 +0x797
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0x2054060?, {0x2054060?, 0xc0011e2270?}, 0xd?, {0x1ced480?, 0xc00076e5b0?})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:783 +0x178
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000bbf7a0, {0x2054060, 0xc0011e2270}, 0xc0014875f0, {0x1ced480, 0xc00076e5b0})
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1089 +0x59e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc00093b1b8, {0x2054060?, 0xc0011e20f0?}, 0xc001307b40)
github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:649 +0x4a5
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ReadResource({{0x2073560?, 0xc00093b1b8?}}, {0x2054060?, 0xc0011e20f0?}, 0xc0013079c0?)
github.com/hashicorp/[email protected]/tf5to6server/tf5to6server.go:119 +0x242
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ReadResource(0x2053fb8?, {0x2054060?, 0xc000f83da0?}, 0xc0013079c0)
github.com/hashicorp/[email protected]/tf6muxserver/mux_server_ReadResource.go:35 +0x1b5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ReadResource(0xc000b16640, {0x2054060?, 0xc000f833e0?}, 0xc00028e900)
github.com/hashicorp/[email protected]/tfprotov6/tf6server/server.go:787 +0x4b1
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ReadResource_Handler({0x1c998c0?, 0xc000b16640}, {0x2054060, 0xc000f833e0}, 0xc0010b8150, 0x0)
github.com/hashicorp/[email protected]/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:431 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002252c0, {0x2063ec0, 0xc0008da680}, 0xc000f9eea0, 0xc000199a40, 0x2d7e8a8, 0x0)
google.golang.org/[email protected]/server.go:1376 +0xdd2
google.golang.org/grpc.(*Server).handleStream(0xc0002252c0, {0x2063ec0, 0xc0008da680}, 0xc000f9eea0, 0x0)
google.golang.org/[email protected]/server.go:1753 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.1()
google.golang.org/[email protected]/server.go:998 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/[email protected]/server.go:996 +0x18c

Error: The terraform-provider-snowflake_v0.76.0 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.`

Expected behavior

Successful import

Code samples and commands
(obvious obfuscations have been made)
CLI command:
terraform import 'module.module_name["username"].snowflake_role_ownership_grant.descriptive_name' "role_one_name"
TF resource:
resource "snowflake_role_ownership_grant" "descriptive_name" {
provider = snowflake.security
depends_on = [module.common, snowflake_role.user]
on_role_name = snowflake_role.role_one.name
to_role_name = snowflake_role.role_two.name
revert_ownership_to_role_name = snowflake_role.role_three.name
current_grants = "REVOKE"
}

Additional context

Add any other context about the problem here.

@bert-ciandt bert-ciandt added the bug Used to mark issues with provider's incorrect behavior label Nov 16, 2023
@sfc-gh-jcieslak sfc-gh-jcieslak self-assigned this Nov 17, 2023
@sfc-gh-jcieslak
Copy link
Collaborator

Hey @bert-ciandt
First of all, If possible, please use snowflake_grant_privileges_to_role. It's our latest implementation of grants (soon we will be adding more resources and the old ones will probably be deprecated and removed at some point).
But, If you would like to import this resource you need to pass 3 parts instead of one ("role_one_name"). The correct id has this form "<on_role_name>|<to_role_name>|<current_grants>". I'm not sure, but I even think that the middle part might be obsolete and your import should look like

terraform import 'module.module_name["username"].snowflake_role_ownership_grant.descriptive_name' "role_one_name||REVOKE"

This may work, but we're currently working on re-designing / designing grant resources and data sources and we're highly discouraging people from using ownership transfers in the Terraform. If there's any other way to solve this other than granting ownership, please go for that instead.

@bert-ciandt
Copy link
Author

Thank you! That import works correctly. I did include the <to_role_name> in the working command. Did not try it without. Please note that the documentation is incorrect:
terraform import snowflake_role_ownership_grant.example rolename

@sfc-gh-jcieslak
Copy link
Collaborator

@bert-ciandt Noted, I'll provide a fix on Monday

@bert-ciandt
Copy link
Author

bert-ciandt commented Nov 20, 2023

@sfc-gh-jcieslak Could you tell me when the decision to re-design grants was made? Just curious. Is the same re-design going to happen for, say, Pulumi?

@sfc-gh-jcieslak
Copy link
Collaborator

sfc-gh-jcieslak commented Nov 21, 2023

@bert-ciandt Hey, I've merged fixed documentation. You can check our statement about grants here. Regarding Pulumi, we're not working on it, but as far as I know, behind the scenes, it uses our provider, so I'm guessing it may have an effect on it.

@sfc-gh-jcieslak
Copy link
Collaborator

sfc-gh-jcieslak commented Nov 23, 2023

Hey @bert-ciandt, Sorry I closed the issue and forgot to address the re-designing grants part. Right now, we are focused on providing a stable provider and reaching version 1.0.0. To do that, we are looking more into issues to solve them and provide a better experience for existing resources and data sources. Grants are kind of special because in GH issues the most raised topic was grants, so we decided to take them and make them more complete and address some of the issues sooner rather than later. Can't really tell when the decision was made, but I was one of our blocks to reach provider stabilization. We also have plans to better reach our users and present changes/plans in a more approachable/informative way, so everyone will be on the same page on where we are and where we are going.
Please, reply or just say that it's fine to close the issue, Thanks :)

@sfc-gh-jcieslak
Copy link
Collaborator

Hey @bert-ciandt, we would appreciate your feedback regarding granting ownership and what you expect for the upcoming grant changes
#2235

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 category:grants
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants