Snowflake-Labs / terraform-provider-snowflake

Terraform provider for managing Snowflake accounts
https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest
MIT License
552 stars 420 forks source link

[Bug]: terraform import snowflake_user_password_policy_attachment - Error: required id format 'user_name|password_policy_name' #3005

Open wpl-sf-nbirch opened 3 months ago

wpl-sf-nbirch commented 3 months ago

Terraform CLI Version

0.87.0

Terraform Provider Version

1.9.4

Terraform Configuration

terraform import snowflake_user_password_policy_attachment.bus_user_attach_90day_policy "DATA_GOVERNANCE|POLICY_MANAGEMENT|SERVICE_ACCOUNT_90_DAY_EXPIRY|SVC_BUSINESS_USER_CONFIDENTIAL"

Category

category:import

Object type(s)

resource:user_password_policy_attachment

Expected Behavior

snowflake_user_password_policy_attachment resource is imported into state

Actual Behavior

unable to import policy attachment

│ Error: required id format 'user_name|password_policy_name', but got: 'DATA_GOVERNANCE|POLICY_MANAGEMENT|SERVICE_ACCOUNT_90_DAY_EXPIRY|SVC_BUSINESS_USER_CONFIDENTIAL'

Steps to Reproduce

Using format provided in docs import a user_password_policy_attachement: Import

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs/resources/user_password_policy_attachment#import

Would you like to implement a fix?

sfc-gh-asawicki commented 3 months ago

Hey @wpl-sf-nbirch.

It seems that we did not alter the import documentation with https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/2485. Can you check if you can import with

terraform import snowflake_user_password_policy_attachment.bus_user_attach_90day_policy <user_name>|<fully_qualified_policy_name>"

?

wpl-sf-nbirch commented 3 months ago

Tried that format also, and get a different error:

│ Error: sql: Scan error on column index 13, name "POLICY_STATUS": converting NULL to string is unsupported

sfc-gh-asawicki commented 3 months ago

Okay, this seems like an entirely different error; I will check it during the current user rework.

sfc-gh-asawicki commented 2 weeks ago

I finally got to this issue.

I can't reproduce it in the newest version of the provider or in v0.87.0. However, I see in the history that we introduced a change for policy reference handling in https://github.com/Snowflake-Labs/terraform-provider-snowflake/pull/2627, which was released in v0.88.0. Please try this one out.

sfc-gh-asawicki commented 1 day ago

Hey @wpl-sf-nbirch. Were you able to validate the newer version?