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

[General Usage]: Newer snowflake_roles resource seems much less convenient than the previous snowflake_role resource #3246

Open
fh-jack-burnett opened this issue Dec 4, 2024 · 2 comments
Labels
general-usage General help/usage questions usage:show_output

Comments

@fh-jack-burnett
Copy link

Terraform CLI Version

1.7.5

Terraform Provider Version

0.98.0

Company Name

No response

Terraform Configuration

No response

Category

category:resource

Object type(s)

No response

Expected Behavior

Our main usecase for the role datasource is to fetch a single role by name, which we could previously do like this:

data "snowflake_role" "this" {
  name = "role1"
}

output "name_output" {
  value = data.snowflake_role.this.name
}

Actual Behavior

To achieve the same behaviour, we now have to do something more like

data "snowflake_roles" "like" {
  like = "role1"
}

output "name_output" {
  value = one(one(data.snowflake_roles.like.roles).show_output).name
}

Steps to Reproduce

It seems like the new resource is much more verbose for this common usecase, where we have to wrap any usage of the source in two one statements - and may also want to add multiple checks to ensure that exactly 1 value is returned, adding several more lines for each source.

Additionally, I am a little confused as to why both roles and show_output are lists, rather than one of them being single value?

How much impact is this issue causing?

Low

Logs

No response

Additional Information

No response

@fh-jack-burnett fh-jack-burnett added the general-usage General help/usage questions label Dec 4, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @fh-jack-burnett. Thanks for reaching out to us

I think we have not shared it anywhere publicly yet, but we had internal discussions about the datasources shape for the V1. Main pointers:

  • for V1 we focus on having a "plural" datasource for each stable object because it covers all the use cases (sometimes much more verbose as you said)
  • after V1 we plan to revisit the topic; the current idea would be to provide 2 more datasources for each object (or to extend the existing datasource with 1. and add just one described in 2.):
    1. id-fetching one with more filtering; the idea would be to have a lightweight object to fetch all objects matching the filters to use it in...
    2. ... the "singular" datasource which has all the details that also the resource has (so it would be essentially a read-only copy of the resource)

We will, however, address it after V1, and after hitting GA.

About the show_output looks, please check our answers in #3074, #3118, and #3084.

@fh-jack-burnett
Copy link
Author

Great thanks for the explanation!
Sounds like a good plan to me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
general-usage General help/usage questions usage:show_output
Projects
None yet
Development

No branches or pull requests

2 participants