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]: Migrate snowflake_role to snowflake_account_role #3037

Closed
myshon opened this issue Sep 3, 2024 · 2 comments
Closed

[General Usage]: Migrate snowflake_role to snowflake_account_role #3037

myshon opened this issue Sep 3, 2024 · 2 comments
Labels
general-usage General help/usage questions

Comments

@myshon
Copy link

myshon commented Sep 3, 2024

Terraform CLI Version

1.8.5

Terraform Provider Version

0.94.1

Terraform Configuration

resource "snowflake_role" "rag_ingestion" {
  name = local.snowflake.role
}

resource "snowflake_account_role" "rag_ingestion" {
  name = local.snowflake.role
}

import {
  id = snowflake_role.rag_ingestion.id
  to = snowflake_account_role.rag_ingestion
}

Category

category:resource

Object type(s)

No response

Expected Behavior

Migration snowflake_role -> snowflake_account_role without DROP ROLE.
I would like to avoid state manipulation using CLI.

Actual Behavior

Removing resource snowflake_role caused resource destroy and drop role.

{"@level":"info","@message":"snowflake_role.rag_ingestion: Destroying... [id=rag_ingestion]","@module":"terraform.ui","@timestamp":"2024-09-03T10:09:48.561785Z","hook":{"resource":{"addr":"snowflake_role.rag_ingestion","module":"","resource":"snowflake_role.rag_ingestion","implied_provider":"snowflake","resource_type":"snowflake_role","resource_name":"rag_ingestion","resource_key":null},"action":"delete","id_key":"id","id_value":"rag_ingestion"},"type":"apply_start"}
{"@level":"info","@message":"snowflake_role.rag_ingestion: Destruction complete after 0s","@module":"terraform.ui","@timestamp":"2024-09-03T10:09:49.449801Z","hook":{"resource":{"addr":"snowflake_role.rag_ingestion","module":"","resource":"snowflake_role.rag_ingestion","implied_provider":"snowflake","resource_type":"snowflake_role","resource_name":"rag_ingestion","resource_key":null},"action":"delete","elapsed_seconds":0},"type":"apply_complete"}

Steps to Reproduce

I've used snowflake role resource

resource "snowflake_role" "rag_ingestion" {
  name = local.snowflake.role
}

After updating to 0.94.x resource has been deprecated in favor of snowflake_account_role.
Therefore, I added new resource with proper import.

resource "snowflake_role" "rag_ingestion" {
  name = local.snowflake.role
}

resource "snowflake_account_role" "rag_ingestion" {
  name = local.snowflake.role
}

import {
  id = snowflake_role.rag_ingestion.id
  to = snowflake_account_role.rag_ingestion
}

Resource has been imported correctly.

{"@level":"info","@message":"Apply complete! Resources: 1 imported, 0 added, 1 changed, 0 destroyed.","@module":"terraform.ui","@timestamp":"2024-09-02T07:18:52.956116Z","changes":{"add":0,"change":1,"import":1,"remove":0,"operation":"apply"},"type":"change_summary"}

In the next run, I tried to remove deprecated resources along with import statement. It ended with

resource "snowflake_account_role" "rag_ingestion" {
  name = local.snowflake.role
}

However, removing resource snowflake_role caused resource destroy and drop role.

{"@level":"info","@message":"snowflake_role.rag_ingestion: Destroying... [id=rag_ingestion]","@module":"terraform.ui","@timestamp":"2024-09-03T10:09:48.561785Z","hook":{"resource":{"addr":"snowflake_role.rag_ingestion","module":"","resource":"snowflake_role.rag_ingestion","implied_provider":"snowflake","resource_type":"snowflake_role","resource_name":"rag_ingestion","resource_key":null},"action":"delete","id_key":"id","id_value":"rag_ingestion"},"type":"apply_start"}
{"@level":"info","@message":"snowflake_role.rag_ingestion: Destruction complete after 0s","@module":"terraform.ui","@timestamp":"2024-09-03T10:09:49.449801Z","hook":{"resource":{"addr":"snowflake_role.rag_ingestion","module":"","resource":"snowflake_role.rag_ingestion","implied_provider":"snowflake","resource_type":"snowflake_role","resource_name":"rag_ingestion","resource_key":null},"action":"delete","elapsed_seconds":0},"type":"apply_complete"}

How to migrate snowflake_role -> snowflake_account_role without DROP ROLE? I would like to avoid state manipulation using CLI.

How much impact is this issue causing?

Medium

Logs

No response

Additional Information

No response

@myshon myshon added the general-usage General help/usage questions label Sep 3, 2024
@sfc-gh-asawicki
Copy link
Collaborator

Hey @myshon. Thanks for reaching out to us.

If you don't want to use terraform rm as described in our resource migration guide, you can use the equivalent: removed block (https://developer.hashicorp.com/terraform/language/resources/syntax#removing-resources).

@sfc-gh-asawicki
Copy link
Collaborator

Closing the issue due to inactivity. Please create a new one if needed.

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

No branches or pull requests

2 participants