Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Overview

This document provides instructions on how to connect to an API to import data from this application into your instance of Zilla.

In this guide, you will:

  1. Launch your application from inside Zilla

  2. Set up an API configuration

  3. Send your data securely to Zilla

Step-by-Step Instructions

1. Create Role

  • Login to your Snowflake account and switch role to ACCOUNTADMIN.

  • Click on Account tab.

  • Go to Roles tab and click on Create icon.

  • Create a Role by entering a Name and selecting Parent Role, then click Finish.

2. Create User

  • Go to Users tab and click on Create icon.

  • In General section enter User Name and Password details. ZILLAREADERUSER is an example, you can choose any name you want. Note down the User Name for later steps. Click Next.

  • In Advanced section fill in the details, see Note below.

    Note: Login Name should be the User Name provided in the General section, Email should be an email address from your organization, zillareaderuser@example.com is just an example. Click Next.

  • In Preferences section, select the role created in step 1 above as Default Role and click Finish.

3. Create Key Pair Authentication for the User

  • Step 1: 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

  • Step 2: Generate a Public Key

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

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

  • Step 4: Assign the Public Key to the Snowflake User (e.g., ZILLAREADERUSER) created in step 2 above with the following SQL query:

// Execute this query to enable admin privilege so that we can modify user
USE ROLE ACCOUNTADMIN;
  • Execute the following query substituting user created in step 2 above for ZILLAREADERUSER and the public key, see Note below:

// 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)

  • Navigate to the Warehouses tab and Select your Warehouse. Click on Grant Privileges.

  • Enter the Privileges to grant as USAGE and Grant privileges to role (ZILLAREADERROLE). Click Grant.

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

  • Navigate to the Worksheets tab. Write the following query on a worksheet. To summarize, this SQL statement creates a new database that contains views that pull from the primary Snowflake Database. The role and user are only granted access to these views in the new database. Substitute ZILLAREADERUSER with the User Name created in step 2 above.

    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 * from SNOWFLAKE.ACCOUNT_USAGE.USERS;
    
    create view ZILLA_SNOWFLAKE_USAGE.ACCOUNT_USAGE.GRANTS_TO_USERS 
        as select * 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;

6. Set up Snowflake Application Integration on Zilla:

  • Navigate to your Snowflake instance in your library. Click Sync now in the top right corner. This pop-up should appear, click on the slider below API Integration to enable it.

  • Here fill in the details as follows,

    • RSA Private Key: The PVT RSA key generated in step 3 above. You can print the key on the terminal using $cat rsa_key.p8 command. Note that key shall be copied with -----BEGIN PRIVATE KEY----- and -----END PRIVATE KEY----- otherwise app will throw an error. Paste the key in the input box.

    • RSA Private Key Passphrase: If you created an encrypted RSA PVT key then a passphrase to decrypt the key shall be provided here. If you have not created an encrypted key using -nocrypt flag, leave this blank.

    • Snowflake Account Id: If your snowflake URL is https://unaXXXXX.us-east-1.snowflakecomputing.com/ then unaXXXXX.us-east-1 is your account id.

    • Account Username: In our case, it’s ZILLAREADERUSER. If you have chosen a custom name above, provide that name.

    • Account User Role: In our case, it’s ZILLAREADERROLE. If you have chosen any custom role name above, provide that name.

    • Warehouse name ( Where SNOWFLAKE db & ACCOUNT_USAGE schema is located ): Name of the warehouse which has the SNOWFLAKE database & ACCOUNT_USAGE schema. Use show warehouses; command to see available warehouses in your account.

  • After filling in the above details click on Next.

  • You will see a configuration stored success toast as well as a small dialog saying In the next step, you will be asked to log in to Snowflake, and then the data sync will start automatically. Click Next.

When you have finished with all the steps above, review the information in Zilla that was synced.

Having trouble? Try our Troubleshooting articles or contact support@zillasecurity.com.

  • No labels