
이제는 이번 실습 시리즈의 원본인 Snowflake의 frostbyte팀이 생성한 Tasty Bytes 데이터의 RBAC 구성을 따라 해보겠습니다. 본 실습에서는 웨어하우스와 역할을 일부만 생성하여 간소화하였는데, 원본을 참조하고 싶으면 frostbyte 셋업 스크립트를 확인해 볼 수도 있습니다
본 실습은 다음과 같은 형태로 RBAC을 구성하게 됩니다

+Add new를 클릭하여 새 SQL File을 만듭니다// sysadmin으로 역할 전환 USE ROLE sysadmin ; // 웨어하우스 tasty_dev_wh 생성 CREATE OR REPLACE WAREHOUSE tasty_dev_wh WAREHOUSE_SIZE = 'xsmall' WAREHOUSE_TYPE = 'standard' AUTO_SUSPEND = 60 AUTO_RESUME = TRUE INITIALLY_SUSPENDED = TRUE ; // 확인 SHOW WAREHOUSES LIKE 'tasty%';
역할(role)을 추가로 생성합니다
// securityadmin으로 역할 전환 USE ROLE securityadmin ; // 역할 추가 CREATE ROLE IF NOT EXISTS tasty_data_engineer ; CREATE ROLE IF NOT EXISTS tasty_dev ; SET MYUSERNAME = current_user(); GRANT ROLE tasty_data_engineer TO USER IDENTIFIER($MYUSERNAME); GRANT ROLE tasty_dev TO USER IDENTIFIER($MYUSERNAME); // 확인 SHOW ROLES LIKE 'tasty%' ;
데이터베이스 오브젝트에 대한 권한을 부여합니다
// securityadmin으로 역할 전환 USE ROLE securityadmin ; // tasty_db에 대한 사용 권한 GRANT USAGE ON DATABASE frostbyte_tasty_bytes TO ROLE tasty_data_engineer; GRANT USAGE ON DATABASE frostbyte_tasty_bytes TO ROLE tasty_dev; // tasty_db의 모든 스키마에 대한 사용 권한 GRANT USAGE ON ALL SCHEMAS IN DATABASE frostbyte_tasty_bytes TO ROLE tasty_data_engineer; GRANT USAGE ON ALL SCHEMAS IN DATABASE frostbyte_tasty_bytes TO ROLE tasty_dev; // raw_pos 스키마에 대해 모든 권한 GRANT ALL ON SCHEMA frostbyte_tasty_bytes.raw_pos TO ROLE tasty_data_engineer; GRANT ALL ON SCHEMA frostbyte_tasty_bytes.raw_pos TO ROLE tasty_dev; // raw_customer 스키마에 대해 모든 권한 GRANT ALL ON SCHEMA frostbyte_tasty_bytes.raw_customer TO ROLE tasty_data_engineer; GRANT ALL ON SCHEMA frostbyte_tasty_bytes.raw_customer TO ROLE tasty_dev; // raw_pos 스키마 내의 전체 테이블에 대한 모든 권한 GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA frostbyte_tasty_bytes.raw_pos TO ROLE tasty_data_engineer ; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA frostbyte_tasty_bytes.raw_pos TO ROLE tasty_dev ; // raw_customer 스키마 내의 전체 테이블에 대한 모든 권한 GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA frostbyte_tasty_bytes.raw_customer TO ROLE tasty_data_engineer ; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA frostbyte_tasty_bytes.raw_customer TO ROLE tasty_dev ;
웨어하우스 사용 권한을 부여합니다
// demo_build_wh GRANT ALL ON WAREHOUSE demo_build_wh TO ROLE sysadmin; // tasty_de_wh GRANT ALL ON WAREHOUSE tasty_de_wh TO ROLE tasty_data_engineer; // tasty_dev_wh GRANT ALL ON WAREHOUSE tasty_dev_wh TO ROLE tasty_data_engineer; GRANT ALL ON WAREHOUSE tasty_dev_wh TO ROLE tasty_dev;
향후 생성될 테이블에 대한 권한을 부여합니다
// raw_pos 스키마에 생성될 향후 테이블 GRANT ALL ON FUTURE TABLES IN SCHEMA frostbyte_tasty_bytes.raw_pos TO ROLE tasty_data_engineer; GRANT ALL ON FUTURE TABLES IN SCHEMA frostbyte_tasty_bytes.raw_pos TO ROLE tasty_dev; // raw_customer 스키마에 생성될 향후 테이블 GRANT ALL ON FUTURE TABLES IN SCHEMA frostbyte_tasty_bytes.raw_customer TO ROLE tasty_data_engineer; GRANT ALL ON FUTURE TABLES IN SCHEMA frostbyte_tasty_bytes.raw_customer TO ROLE tasty_dev;