Skip to content

Commit

Permalink
Support passing in access key id and secret key via env var
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z committed Dec 6, 2024
1 parent 9f5c5e8 commit fadef55
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@
"properties": {
"endpoint_url": {"type": ["string", "null"]},
"bucket_name": {"type": "string"},

# one of
"access_key_id": {"type": "string"},
"access_key_id_env_var": {"type": "string"},

# one of
"secret_key": {"type": "string"},
"secret_key_env_var": {"type": "string"},
},
"additionalProperties": False,
"required": ["endpoint_url", "bucket_name", "access_key_id", "secret_key"],
"required": ["endpoint_url", "bucket_name"],
}

bucket_config_schema = {
Expand Down Expand Up @@ -90,8 +96,8 @@ def __init__(self, bucket_config, repo_config, workspace_dir: str):
name: boto3.resource(
"s3",
endpoint_url=config["endpoint_url"],
aws_access_key_id=config["access_key_id"],
aws_secret_access_key=config["secret_key"],
aws_access_key_id=config["access_key_id"] or os.environ[config["access_key_id_env_var"]],
aws_secret_access_key=config["secret_key"] or os.environ[config["secret_key_env_var"]],
).Bucket(config["bucket_name"])
for name, config in bucket_config.items()
}
Expand Down

0 comments on commit fadef55

Please sign in to comment.