terraform-provider-snowflake icon indicating copy to clipboard operation
terraform-provider-snowflake copied to clipboard

After using snowflake_tag_association to set tag on account, subsequent terraform plan/apply fail with "error listing tag associations".

Open pstDnb opened this issue 2 years ago • 2 comments

Provider Version

0.64.0

Terraform Version

1.3.9

Describe the bug

The first attempt to set tags on the account using snowflake_tag_association succeeds. However, afterwards any attempt to run terraform plan or apply fail with error listing tag associations, because the GET_TAG function is invoked using account name (e.g SANDPIT01_AWS_EW1_DEV instead of account locator (e.g. KP44023).

Example of failing SQL query:

SELECT SYSTEM$GET_TAG('"LIBRARY_FEATURE_PAALDEV"."TAGS"."ACCOUNT_TYPE"', '"SANDPIT01_AWS_EW1_DEV"', 'ACCOUNT') TAG_VALUE WHERE TAG_VALUE IS NOT NULL;

The above query succeeds if SANDPIT01_AWS_EW1_DEV is replaced with KP44023.

It is not an option to use account locator in object_identifier, since the SQL generated to set the tag explicitly mentions the account:

ALTER ACCOUNT "SANDPIT01_AWS_EW1_DEV" SET TAG "LIBRARY_FEATURE_PAALDEV"."TAGS"."ACCOUNT_GROUP" = 'SANDPIT01';

(The Snowflake documentation specifies a syntax without account name for 'ALTER ACCOUNT SET TAG', and even though it works with account name, the same query fails when replacing account name with account locator.)

Expected behavior

When listing tag associations on the account (during plan or apply), the provider should use a query that correctly retrieves the tag.

Code samples and commands

Please add code examples and commands that were run to cause the problem.

Additional context

Add any other context about the problem here.

pstDnb avatar Jun 26 '23 08:06 pstDnb

@pstDnb thank you for reporting this issue. We will look into it and get back to you. Also, I think this ticket is related to #1926 . What we will need to do is refactor the snowflake_tag_association resource, as it does not seem to handle identifiers well in every situation.

sfc-gh-swinkler avatar Jul 25 '23 23:07 sfc-gh-swinkler

We have same error using snowflake_tag_association to set tag on VIEW. It's working fine on TABLE.

jia-ying-lin avatar May 14 '24 15:05 jia-ying-lin

Hey @jia-ying-lin, @pstDnb. We will address this issue as part of https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#preparing-essential-ga-objects-for-the-provider-v1.

sfc-gh-asawicki avatar May 15 '24 07:05 sfc-gh-asawicki