Skip to content

Commit

Permalink
fix: ingestor role to have s3 access (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
slesaad authored Jun 6, 2024
1 parent 151edec commit 8863d92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ingest_api/infrastructure/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from getpass import getuser
from typing import Optional
from typing import List, Optional

import aws_cdk
from pydantic import AnyHttpUrl, BaseSettings, Field, constr
Expand All @@ -8,6 +8,15 @@


class IngestorConfig(BaseSettings):
# S3 bucket names where TiTiler could do HEAD and GET Requests
# specific private and public buckets MUST be added if you want to use s3:// urls
# You can whitelist all bucket by setting `*`.
# ref: https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-arn-format.html
buckets: List = ["*"]

# S3 key pattern to limit the access to specific items (e.g: "my_data/*.tif")
key: str = "*"

stage: str = Field(
description=" ".join(
[
Expand Down
8 changes: 8 additions & 0 deletions ingest_api/infrastructure/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def __init__(

# create lambda
self.api_lambda = self.build_api_lambda(**build_api_lambda_params)
self.api_lambda.add_to_role_policy(
iam.PolicyStatement(
actions=["s3:GetObject"],
resources=[
f"arn:aws:s3:::{bucket}/{config.key}" for bucket in config.buckets
],
)
)

# create API
self.api: aws_apigatewayv2_alpha.HttpApi = self.build_api(
Expand Down

0 comments on commit 8863d92

Please sign in to comment.