|
24 | 24 | import jwt |
25 | 25 | import requests |
26 | 26 |
|
| 27 | +import boto3 |
27 | 28 | from confluent_kafka import Producer |
28 | 29 |
|
29 | 30 | with open("conf/config.json", "r") as file: |
30 | 31 | CONFIG = json.load(file) |
31 | 32 |
|
32 | | -with open(CONFIG["topicsConfig"], "r") as file: |
33 | | - TOPICS = json.load(file) |
| 33 | +aws_session = boto3.Session() |
| 34 | +aws_s3 = aws_session.resource('s3', verify=False) |
34 | 35 |
|
35 | | -with open(CONFIG["accessConfig"], "r") as file: |
36 | | - ACCESS = json.load(file) |
| 36 | +if CONFIG["topicsConfig"].startswith("s3://"): |
| 37 | + name_parts = CONFIG["topicsConfig"].split('/') |
| 38 | + bucket_name = name_parts[2] |
| 39 | + bucket_object = "/".join(name_parts[3:]) |
| 40 | + TOPICS = json.loads(aws_s3.Bucket(bucket_name).Object(bucket_object).get()["Body"].read().decode("utf-8")) |
| 41 | +else: |
| 42 | + with open(CONFIG["topicsConfig"], "r") as file: |
| 43 | + TOPICS = json.load(file) |
| 44 | + |
| 45 | +if CONFIG["accessConfig"].startswith("s3://"): |
| 46 | + name_parts = CONFIG["accessConfig"].split('/') |
| 47 | + bucket_name = name_parts[2] |
| 48 | + bucket_object = "/".join(name_parts[3:]) |
| 49 | + ACCESS = json.loads(aws_s3.Bucket(bucket_name).Object(bucket_object).get()["Body"].read().decode("utf-8")) |
| 50 | +else: |
| 51 | + with open(CONFIG["accessConfig"], "r") as file: |
| 52 | + ACCESS = json.load(file) |
37 | 53 |
|
38 | 54 | TOKEN_PROVIDER_URL = CONFIG["tokenProviderUrl"] |
39 | | -print("Loaded config") |
| 55 | +print("Loaded configs") |
40 | 56 |
|
41 | 57 | token_public_key_encoded = requests.get(CONFIG["tokenPublicKeyUrl"], verify=False).json()["key"] |
42 | 58 | TOKEN_PUBLIC_KEY = serialization.load_der_public_key(base64.b64decode(token_public_key_encoded)) |
|
0 commit comments