Can we encrypt stored procedures in Snowflake similar to what we do in SQL Server?
For example, similar to
CREATE PROCEDURE #EncryptSP
WITH ENCRYPTION
AS
QUERY HERE
GO
Can we encrypt stored procedures in Snowflake similar to what we do in SQL Server?
For example, similar to
CREATE PROCEDURE #EncryptSP
WITH ENCRYPTION
AS
QUERY HERE
GO
Everything in Snowflake databases is encrypted, so I believe the issue is allowing users to run a stored procedure but not see its contents. That's not a problem.
-- Using a database called TEST
grant usage on database test to role public;
grant usage on schema public to role public;
-- Create a secure procedure and run it as SYSADMIN (or whatever role you want)
create or replace secure procedure test.public.hello_world()
returns string
language JavaScript
execute as owner
as
$$
return "Hello world";
$$;
-- Allow users in the PUBLIC role to run the procedure
grant usage on procedure HELLO_WORLD() to role PUBLIC;
-- Test that users in role PUBLIC can run the procedure
use role public;
use database test;
use schema public;
call HELLO_WORLD();
-- However, they cannot see the stored procedure
select get_ddl('procedure', 'HELLO_WORLD()');
-- The owner can.
use role SYSADMIN;
select get_ddl('procedure', 'HELLO_WORLD()');