-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcreate_service.sql
More file actions
72 lines (59 loc) · 2.89 KB
/
Copy pathcreate_service.sql
File metadata and controls
72 lines (59 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- Run these first
-- https://github.com/Snowflake-Labs/sfguide-getting-started-with-cortex-analyst/blob/main/create_snowflake_objects.sql
-- https://github.com/Snowflake-Labs/sfguide-getting-started-with-cortex-analyst/blob/main/load_data.sql
-- https://github.com/Snowflake-Labs/sfguide-getting-started-with-cortex-analyst/blob/main/cortex_search_create.sql
USE ROLE accountadmin;
CREATE ROLE service_user_role;
CREATE DATABASE IF NOT EXISTS app_db;
GRANT OWNERSHIP ON DATABASE app_db TO ROLE service_user_role COPY CURRENT GRANTS;
GRANT BIND SERVICE ENDPOINT ON ACCOUNT TO ROLE service_user_role;
CREATE COMPUTE POOL app_compute_pool
MIN_NODES = 1
MAX_NODES = 1
INSTANCE_FAMILY = CPU_XS
AUTO_SUSPEND_SECS = 3600;
GRANT USAGE, MONITOR ON COMPUTE POOL app_compute_pool TO ROLE service_user_role;
GRANT OWNERSHIP ON SCHEMA app_db.public TO ROLE service_user_role;
GRANT CREATE NETWORK RULE ON SCHEMA app_db.public TO ROLE accountadmin;
CREATE OR REPLACE NETWORK RULE app_db.public.dependencies_network_rule
MODE = EGRESS
TYPE = HOST_PORT
VALUE_LIST = ('pypi.python.org', 'pypi.org', 'cdn.pypi.org','pythonhosted.org', 'files.pythonhosted.org', 'github.com', 'githubusercontent.com');
CREATE EXTERNAL ACCESS INTEGRATION dependencies_access_integration
ALLOWED_NETWORK_RULES = (app_db.public.dependencies_network_rule)
ENABLED = true;
GRANT USAGE ON INTEGRATION dependencies_access_integration TO ROLE service_user_role;
-- Grant restricted caller privileges to service_user_role
GRANT CALLER USAGE ON DATABASE cortex_analyst_demo TO ROLE service_user_role;
GRANT INHERITED CALLER USAGE ON ALL SCHEMAS IN DATABASE cortex_analyst_demo TO ROLE service_user_role;
GRANT INHERITED CALLER USAGE,READ ON ALL STAGES IN SCHEMA cortex_analyst_demo.revenue_timeseries TO ROLE service_user_role;
GRANT INHERITED CALLER SELECT ON ALL TABLES IN DATABASE cortex_analyst_demo TO ROLE service_user_role;
GRANT CALLER USAGE ON CORTEX SEARCH SERVICE cortex_analyst_demo.revenue_timeseries.product_line_search_service TO ROLE service_user_role;
GRANT CALLER USAGE ON DATABASE snowflake TO ROLE service_user_role;
GRANT INHERITED CALLER USAGE ON ALL SCHEMAS IN DATABASE snowflake TO ROLE service_user_role;
GRANT INHERITED CALLER USAGE ON ALL FUNCTIONS IN DATABASE snowflake TO ROLE service_user_role;
USE ROLE service_user_role;
USE DATABASE app_db;
CREATE IMAGE REPOSITORY IF NOT EXISTS repo;
SHOW IMAGE REPOSITORIES IN SCHEMA app_db.public;
SHOW IMAGES IN IMAGE REPOSITORY app_db.public.repo;
CREATE SERVICE analyst_ui
IN COMPUTE POOL app_compute_pool
FROM SPECIFICATION $$
spec:
containers:
- name: ui
image: <registry>/<repo>/<image>:<version>
readinessProbe:
port: 8080
path: /healthcheck
endpoints:
- name: chat
port: 8080
public: true
capabilities:
securityContext:
executeAsCaller: true
$$
MIN_INSTANCES=1
MAX_INSTANCES=1;