{Terraform} Snowflake

 

https://registry.terraform.io/providers/Snowflake-Labs/snowflake/latest/docs

https://qiita.com/hiro-wa/items/4aeb1c7346714d6b5e53
https://dev.classmethod.jp/articles/snowflake-terraform-try/

 

export SNOWFLAKE_USER=1111111111
export SNOWFLAKE_PASSWORD='1111111111111111111111'

 

 

cat <<-'EOF' > main.tf

terraform {
  required_providers {
    snowflake = {
      source  = "Snowflake-Labs/snowflake"
      version = ">= 1.0.0"
    }
  }
}

provider "snowflake" {
  organization_name      = "1111111"
  account_name           = "1111111"
 
  role  = "ACCOUNTADMIN"
}


resource "snowflake_warehouse" "wh01" {
  name = "wh01"
  warehouse_size = "xsmall"
  auto_suspend = 60
}

resource "snowflake_account_role" "role01" {
  name     = "role01"
}


resource "snowflake_user" "user01" {
  name              = "user01"
  default_warehouse = snowflake_warehouse.wh01.name
  default_role      = snowflake_account_role.role01.name
}


resource "snowflake_database" "db01" {
  name = "db01"
}


resource "snowflake_schema" "schema01" {
  database            = snowflake_database.db01.name
  name                = "schema01"
}

 


EOF


cat main.tf

terraform init
terraform fmt
terraform -version

 

terraform plan

 

terraform apply -auto-approve

 

terraform destroy -auto-approve