-- set variables (these need to be uppercase)
set abt_snwoflake_role = 'YOUR_ROLE'; // field to be defined by you
set abt_snowflake_username = 'YOUR_USER_NAME'; // field to be defined by you
set abt_snowflake_warehouse = 'YOUR_WAREHOUSE';// field to be defined by you
set abt_snowflake_database = 'YOUR_DATABASE';// field to be defined by you
set abt_snowflake_schema = 'YOUR_SCHEMA'; // field to be defined by you
-- set user password
set airbyte_password = 'your_password'; // field to be defined by you
begin;
-- create your role
use role securityadmin;
create role if not exists identifier($abt_snwoflake_role);
grant role identifier($abt_snwoflake_role) to role SYSADMIN;
-- create your user
create user if not exists identifier($abt_snowflake_username)
password = $airbyte_password
default_role = $abt_snwoflake_role
default_warehouse = $abt_snowflake_warehouse;
grant role identifier($abt_snwoflake_role) to user identifier($abt_snowflake_username);
-- change role to sysadmin for warehouse / database steps
use role sysadmin;
-- create your warehouse
create warehouse if not exists identifier($abt_snowflake_warehouse)
warehouse_size = xsmall
warehouse_type = standard
auto_suspend = 60
auto_resume = true
initially_suspended = true;
-- create your database
create database if not exists identifier($abt_snowflake_database);
-- grant your warehouse access
grant USAGE
on warehouse identifier($abt_snowflake_warehouse)
to role identifier($abt_snwoflake_role);
-- grant your database access
grant OWNERSHIP
on database identifier($abt_snowflake_database)
to role identifier($abt_snwoflake_role);
commit;
begin;
USE DATABASE identifier($abt_snowflake_database);
-- create schema for Airbyte data
CREATE SCHEMA IF NOT EXISTS identifier($abt_snowflake_schema);
commit;
begin;
-- grant Airbyte schema access
grant OWNERSHIP
on schema identifier($abt_snowflake_schema)
to role identifier($abt_snwoflake_role);
commit;