Files
mtusi2026lab6/scripts/render-s3-config.py
T

33 lines
932 B
Python

"""Write the local SeaweedFS identity file from .env. The file is gitignored."""
import json
from pathlib import Path
root = Path(__file__).resolve().parents[1]
env = {}
for line in (root / ".env").read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#") or "=" not in line:
continue
key, value = line.split("=", 1)
env[key] = value
out = root / "infra" / "seaweed" / "s3.json"
out.parent.mkdir(parents=True, exist_ok=True)
document = {
"identities": [
{
"name": "app",
"credentials": [
{
"accessKey": env["S3_ACCESS_KEY"],
"secretKey": env["S3_SECRET_KEY"],
}
],
"actions": ["Admin", "Read", "List", "Write", "Tagging"],
}
]
}
out.write_text(json.dumps(document), encoding="utf-8")
print("wrote infra/seaweed/s3.json")