Zsuzsanna Orban-Nagy
01/10/2023, 1:32 PMfrom dagster import job, op
from dagster_snowflake import snowflake_resource
@op(required_resource_keys={'snowflake'})
def get_one(context):
context.resources.snowflake.execute_query('SELECT 1')
@job(resource_defs={'snowflake': snowflake_resource})
def my_snowflake_job():
get_one()
my_snowflake_job.execute_in_process(
run_config={
'resources': {
'snowflake': {
'config': {
'account': {'env': 'SNOWFLAKE_ACCOUNT'},
'user': {'env': 'SNOWFLAKE_USER'},
'password': {'env': 'SNOWFLAKE_PASSWORD'},
'database': {'env': 'SNOWFLAKE_DATABASE'},
'schema': {'env': 'SNOWFLAKE_SCHEMA'},
'warehouse': {'env': 'SNOWFLAKE_WAREHOUSE'},
}
}
}
}
)
and I’d like to use private key as in this Snowflake documentation: https://docs.snowflake.com/en/user-guide/python-connector-example.html#label-python-key-pair-authn-rotation
import snowflake.connector
import os
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives.asymmetric import dsa
from cryptography.hazmat.primitives import serialization
with open("<path>/rsa_key.p8", "rb") as key:
p_key= serialization.load_pem_private_key(
key.read(),
password=os.environ['PRIVATE_KEY_PASSPHRASE'].encode(),
backend=default_backend()
)
pkb = p_key.private_bytes(
encoding=serialization.Encoding.DER,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption())
ctx = snowflake.connector.connect(
user='<user>',
account='<account_identifier>',
private_key=pkb,
warehouse=WAREHOUSE,
database=DATABASE,
schema=SCHEMA
)
cs = ctx.cursor()
but when I have tried to use in the above dagster code the private key parameter, I have got this error message:
dagster._core.errors.DagsterInvalidConfigError: Error in config for resource snowflake
Error 1: Received unexpected config entry "private_key" at path root:config.
Error 2: Missing required config entry "password" at path root:
Does the dagster-snowflake library ready for private key authentication?
Thank your in advance for your response.
@Laszlo Benczesandy
01/10/2023, 5:30 PMjamie
01/10/2023, 5:34 PMZsuzsanna Orban-Nagy
01/11/2023, 8:24 AMjamie
01/17/2023, 5:17 PMZsuzsanna Orban-Nagy
01/17/2023, 5:18 PMLaszlo Bencze
01/20/2023, 11:37 AMjamie
01/20/2023, 1:46 PMLaszlo Bencze
01/20/2023, 2:30 PMZsuzsanna Orban-Nagy
01/20/2023, 2:54 PMERROR: No matching distribution found for dagster==1.1.12
As I see on the https://pypi.org/project/dagster/ that there isn’t 1.1.12 version. Could you help on this?jamie
01/20/2023, 2:58 PM1.1.11
and dagster-snowflake 0.17.11
should have the change. I think we are releasing .12 to fix an unrelated regression, and you can update to that once the release is done and pypi is back to normal. until then, the .11 versions should work for youZsuzsanna Orban-Nagy
01/23/2023, 2:24 PMTypeError: load_pem_private_key() missing 1 required positional argument: 'password'
2. When I use private_key_password
with `None`value: Error 1: Value at path root:config:private_key_password must not be None. Expected "(String | { env: String })"
3. When I use private_key_password
with 'None'
value (as String): TypeError: Password was given but private key is not encrypted.
Please help me how I can configure dagster-snowflake resource when there isn’t any private-key encryption or password.
Thank you in advance.jamie
01/23/2023, 4:44 PMZsuzsanna Orban-Nagy
01/24/2023, 10:19 AMThe above exception was caused by the following exception:
TypeError: Password was given but private key is not encrypted.
error message.jamie
01/25/2023, 12:30 AMZsuzsanna Orban-Nagy
02/01/2023, 2:05 PMjamie
02/01/2023, 3:53 PMpassword
parameter is non-optional, so even if we pass a None from our end, it fails within third-party code. However, Snowflake claims that non-password key pairs should work, I just haven’t been able to find any documentation showing how to do key pair auth without the function that fails without a passwordLaszlo Bencze
03/03/2023, 7:58 AMjamie
03/03/2023, 3:29 PMEdina Karpati
03/09/2023, 4:53 PM