Skip to content

Commit

Permalink
feat(ingestor): Add flag to enable requester pays
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Dec 1, 2022
1 parent 51eb26b commit efc160d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/ingestor-api/runtime/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class Settings(BaseSettings):
description="ARN of AWS Role used to validate access to S3 data"
)

requester_pays: Optional[bool] = Field(
description="Path from where to serve this URL.", default=False
)

class Config(AwsSsmSourceConfig):
env_file = ".env"

Expand Down
8 changes: 7 additions & 1 deletion lib/ingestor-api/runtime/src/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ def s3_object_is_accessible(bucket: str, key: str):
"""
Ensure we can send HEAD requests to S3 objects.
"""
from .main import settings

client = boto3.client("s3", **get_s3_credentials())
try:
client.head_object(Bucket=bucket, Key=key)
client.head_object(
Bucket=bucket,
Key=key,
**{"RequestPayer": "requester"} if settings.requester_pays else {},
)
except client.exceptions.ClientError as e:
raise ValueError(
f"Asset not accessible: {e.__dict__['response']['Error']['Message']}"
Expand Down

0 comments on commit efc160d

Please sign in to comment.