1. Create Role

2. Create User

3. Create Key Pair Authentication for the User

a. Generate the Private Key

To generate an unencrypted version, use the following command:

$ openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8 -nocrypt

To generate an encrypted version, use the following command (which omits “-nocrypt”):

$ openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out rsa_key.p8

b. Generate a Public Key

$ openssl rsa -in rsa_key.p8 -pubout -out rsa_key.pub

c. Store the Private and Public Keys Securely: Store these sensitive keys securely so that no one can access them.

d. Assign the Public Key to the Snowflake User (e.g., ZILLAREADERUSER) created in “2. Create User” section above, with the following SQL query:

// Execute this query to enable admin privilege so that we can modify user
USE ROLE ACCOUNTADMIN;

// Make change to user to associate RSApublic key
ALTER USER ZILLAREADERUSER SET RSA_PUBLIC_KEY='MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC........;


Note: To print the contents of the public key type $ cat rsa_key.pub on the terminal. The public key assigned is without the beginning and end part of it, i.e., -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- respectively.

4. Give the Warehouse Grant Privileges to Role (ZILLAREADERROLE)

5. Give the DATABASE Grant Privileges to Role (ZILLAREADERROLE)

use role ACCOUNTADMIN;

use warehouse ZILLA;

create database ZILLA_SNOWFLAKE_USAGE;

create schema ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE;



create view ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE.USERS 
    as select USER_ID,NAME,CREATED_ON,DELETED_ON,LOGIN_NAME,DISPLAY_NAME,FIRST_NAME,LAST_NAME,EMAIL,MUST_CHANGE_PASSWORD,HAS_PASSWORD,COMMENT,DISABLED,SNOWFLAKE_LOCK,DEFAULT_WAREHOUSE,DEFAULT_NAMESPACE,DEFAULT_ROLE,EXT_AUTHN_DUO,EXT_AUTHN_UID,BYPASS_MFA_UNTIL,LAST_SUCCESS_LOGIN,EXPIRES_AT,LOCKED_UNTIL_TIME,HAS_RSA_PUBLIC_KEY,PASSWORD_LAST_SET_TIME,OWNER,DEFAULT_SECONDARY_ROLE from SNOWFLAKE.ACCOUNT_USAGE.USERS;

create view ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE.GRANTS_TO_USERS 
    as select CREATED_ON,DELETED_ON,"ROLE",GRANTED_TO,GRANTEE_NAME,GRANTED_BY from SNOWFLAKE.ACCOUNT_USAGE.GRANTS_TO_USERS;
    

grant usage on warehouse ZILLA to role ZILLAREADERROLE;
grant usage on database ZILLA_SNOWFLAKE_USAGE to role ZILLAREADERROLE;
grant usage on schema ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE to role ZILLAREADERROLE;    


grant select on view ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE.USERS to role ZILLAREADERROLE;
grant select on view ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE.GRANTS_TO_USERS to role ZILLAREADERROLE;

grant role ZILLAREADERROLE to user ZILLAREADERUSER;

Set up Snowflake Application Integration on Zilla:

image-20240416-175645.pngimage-20240607-084207.pngimage-20240607-084256.pngimage-20240607-084447.pngimage-20240607-084527.pngimage-20240607-085416.png

image-20240607-085526.pngimage-20240607-085721.pngimage-20240607-083725.png