chore: Update alphaworx_zen_hk_live init.py to query new secret
I decided to put all alphaworx api keys in one secret. It's easier this way.
This commit is contained in:
1 parent
74b88b003e
commit
ddabc744f2
1 file changed
+15
-6
@@ -35,8 +35,8 @@ def update_env_file(path, env_vars: dict):
|
||||
|
||||
|
||||
def get_secret():
|
||||
secret_name = "alphaworx-binance-api-keys"
|
||||
region_name = "ap-northeast-1"
|
||||
secret_name = "alphaworx_api_keys"
|
||||
region_name = "us-east-1"
|
||||
profile_name = "bts-ap-northeast-1"
|
||||
session = Session(profile_name=profile_name)
|
||||
client = session.client(
|
||||
@@ -77,10 +77,19 @@ def _run():
|
||||
exit(1)
|
||||
secret = json.loads(secret_str)
|
||||
env_vars = {}
|
||||
if "api-key" in secret:
|
||||
env_vars["BINANCE_API_KEY"] = secret["api-key"]
|
||||
if "secret-key" in secret:
|
||||
env_vars["BINANCE_SECRET_KEY"] = secret["secret-key"]
|
||||
|
||||
def set_env_var(key_name: str, *json_path):
|
||||
try:
|
||||
val = secret[json_path[0]]
|
||||
for p in json_path[1:]:
|
||||
val = val[p]
|
||||
env_vars[key_name] = val
|
||||
print(f"Set {key_name}={val} ({'.'.join(json_path)})")
|
||||
except KeyError:
|
||||
print(f"Failed to set {key_name}= ({'.'.join(json_path)})")
|
||||
|
||||
set_env_var("BINANCE_API_KEY", "binance", "prod", "api_key")
|
||||
set_env_var("BINANCE_SECRET_KEY", "binance", "prod", "secret_key")
|
||||
update_env_file(f"{this_dir}/.env.local", env_vars)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user