Skip to content

Commit

Permalink
Merge pull request #156 from NASA-IMPACT/dev
Browse files Browse the repository at this point in the history
Include external downloader role in sentinel-input-files bucket policy.
  • Loading branch information
sharkinsspatial authored Jul 8, 2021
2 parents 145b9a8 + 66ae697 commit a3f6235
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/dev_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
HLS_MAXV_CPUS: ${{ secrets.HLS_MAXV_CPUS }}
HLS_REPLACE_EXISTING: ${{ secrets.HLS_REPLACE_EXISTING }}
HLS_SSH_KEYNAME: ${{ secrets.HLS_SSH_KEYNAME }}
HLS_DOWNLOADER_FUNCTION_ARN: ${{ secrets.HLS_DOWNLOADER_FUNCTION_ARN }}

steps:
- uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/production_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
HLS_MAXV_CPUS: ${{ secrets.HLS_MAXV_CPUS }}
HLS_REPLACE_EXISTING: ${{ secrets.HLS_REPLACE_EXISTING }}
HLS_SSH_KEYNAME: ${{ secrets.HLS_SSH_KEYNAME }}
HLS_DOWNLOADER_FUNCTION_ARN: ${{ secrets.HLS_DOWNLOADER_FUNCTION_ARN }}

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions environment.sh.sample
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ HLS_REPLACE_EXISTING=true
# ssh keyname for use with Batch instance debugging.
HLS_SSH_KEYNAME=hls-mount

# Sentinel serverless downloader function role arn.
HLS_DOWNLOADER_FUNCTION_ARN=something

# Use Cloudwatch metrics for containers
# HLS_USE_CLOUD_WATCH=true

Expand Down
14 changes: 14 additions & 0 deletions stack/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ def getenv(key, default):
"HLS_LANDSAT_SNS_TOPIC", "arn:aws:sns:us-west-2:673253540267:public-c2-notify"
)

DOWNLOADER_FUNCTION_ARN = getenv("HLS_DOWNLOADER_FUNCTION_ARN", None)

# Stack named resources
SENTINEL_INPUT_BUCKET = f"{STACKNAME}-sentinel-input-files"
LAADS_BUCKET = f"{STACKNAME}-laads-bucket"
Expand Down Expand Up @@ -658,6 +660,18 @@ def __init__(self, scope: core.Construct, id: str, **kwargs) -> None:
self.laads_cron.function.add_to_role_policy(self.laads_bucket_read_policy)
self.laads_available.function.add_to_role_policy(self.laads_bucket_read_policy)

if DOWNLOADER_FUNCTION_ARN:
self.sentinel_input_bucket.add_to_resource_policy(
aws_iam.PolicyStatement(
resources=[
self.sentinel_input_bucket.bucket_arn,
f"{self.sentinel_input_bucket.bucket_arn}/*",
],
actions=["s3:PutObject*", "s3:Abort*"],
principals=[aws_iam.ArnPrincipal(DOWNLOADER_FUNCTION_ARN)]
)
)

self.sentinel_input_bucket_policy = aws_iam.PolicyStatement(
resources=[
self.sentinel_input_bucket.bucket_arn,
Expand Down

0 comments on commit a3f6235

Please sign in to comment.