Error: Role 'SECURITYADMIN', which was previously activated in this session, is no longer available to the executing user.│

Provider: Snowflake
Provider version: ~0.65.0
Terraform cloud version: 1.3.9
I ran Terraform plan to upgrade to Terraform provider 0.65.0. The plan ran successfully. However, upon running Terraform apply, I got this error: (for SECURITYADMIN, ACCOUNTADMIN and SYSADMIN)
│ Error: 003048 (42501): Role ‘SECURITYADMIN’, which was previously activated in this session, is no longer available to the executing user. Login again to create a new session.

Afterwards, running Terraform plan, results into the following error:
Error: could not retrieve session id err = 390186 (08004): Role ‘SECURITYADMIN’ specified in the connect string is not granted to this user. Contact your local system administrator, or attempt to login with another role, e.g. PUBLIC.

with provider[“Terraform Registry”].security_admin

on line 32, in provider “snowflake”: looks like this:
provider “snowflake” {
alias = “security_admin”
account = var.account
region = var.region
username = var.username
private_key = var.private_key

I checked that Terraform service account had the ACCOUNTADMIN, SECURITYADMIN and SYSADMIN privileges as per the last plan that ran successfully. I also checked that the users with these roles are setup correctly.

  1. How do I fix this error?
  2. Do I expect to see the Terraform service account as an user on Snowflake?

Please see Guide to asking for help in this forum and Welcome to the forum - please reformat your message first

It certainly sounds rather like you may have configured Terraform to remove some of the permissions that Terraform itself was using to apply the configuration.

However, as you’ve only given use the error on its own, without additional lines of surrounding context, and haven’t shown the rest of your Terraform config, I can’t be sure of that.

I’m not familiar with Snowflake, but I can’t see how Terraform would have access otherwise.