Skip to content

Commit b890e79

Browse files
Merge pull request #308 from NASA-IMPACT/dev
Preparation for Sentinel S2C platform
2 parents 73b3faa + 6bf84aa commit b890e79

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

environment.sh.sample

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/bash
22

33
# Make sure that necessary executables are installed
4-
for b in jq aws
5-
do
6-
command -v $b >/dev/null 2>&1 || { echo >&2 "I require $b but it's not installed. Aborting."; exit 1; }
4+
for b in jq aws; do
5+
command -v $b >/dev/null 2>&1 || {
6+
echo >&2 "I require $b but it's not installed. Aborting."
7+
exit 1
8+
}
79
done
810

911
# Set allexport mode, all variables defined in this block will get exported
@@ -19,15 +21,13 @@ HLS_LAADS_TOKEN="<your token>"
1921
HLS_OUTPUT_BUCKET=hls-global
2022
HLS_OUTPUT_BUCKET_HISTORIC=hls-gobal-historic
2123

22-
2324
# Role for copying to output bucket
2425
HLS_OUTPUT_BUCKET_ROLE_ARN=arn:aws:iam::611670965994:role/gcc-S3Test
2526

2627
# Landsat SNS topic
2728
HLS_LANDSAT_SNS_TOPIC=arn:aws:sns:us-west-2:673253540267:public-c2-notify
2829
HLS_LANDASAT_HISTORIC_SNS_TOPIC=arn:aws:sns:us-west-2:018923174646:landsat-historic-LandsatHistoricTopic643F0596-1TIGFB893SX3B
2930

30-
3131
# Bucket for merged GIBS tile output.
3232
HLS_GIBS_OUTPUT_BUCKET=hls-browse-imagery
3333
HLS_LAADS_BUCKET_BOOTSTRAP=hls-development-laads-bucket
@@ -76,6 +76,9 @@ HLS_SSH_KEYNAME=hls-mount
7676
# Sentinel serverless downloader function role arn.
7777
HLS_DOWNLOADER_FUNCTION_ARN=something
7878

79+
# Number of days after which objects in the Sentinel input buckets expire
80+
HLS_SENTINEL_INPUT_BUCKET_EXPIRATION_DAYS=60
81+
7982
# GCC Specific environment settings.
8083
GCC=false
8184
HLS_GCC_ACCOUNT=account_id
@@ -89,13 +92,14 @@ HLS_GCC_BOUNDARY_ARN=boudary_policy_arn
8992
set +a
9093

9194
# Set environment variables for all outputs set up in cloud formation
92-
stack_info=$(aws cloudformation describe-stacks --stack-name ${HLS_STACKNAME} --output json)
95+
stack_info=$(aws cloudformation describe-stacks --stack-name "${HLS_STACKNAME}" --output json)
9396
if [[ "$stack_info" =~ "OutputKey" ]]; then
9497
l=$(echo "$stack_info" | jq ".Stacks[].Outputs | length")
95-
for ((i=0;i<$l;++i)); do
96-
key=$(echo "$stack_info" | jq ".Stacks[].Outputs[$i].OutputKey" | sed -e 's/^"//' -e 's/"$//')
98+
99+
for ((i = 0; i < l; ++i)); do
100+
key=$(echo "$stack_info" | jq ".Stacks[].Outputs[$i].OutputKey" | sed -e 's/^"//' -e 's/"$//')
97101
keyupper=$(echo "$key" | awk '{print toupper($0)}')
98-
val=$(echo "$stack_info" | jq ".Stacks[].Outputs[$i].OutputValue" | sed -e 's/^"//' -e 's/"$//')
102+
val=$(echo "$stack_info" | jq ".Stacks[].Outputs[$i].OutputValue" | sed -e 's/^"//' -e 's/"$//')
99103
export "HLSSTACK_$keyupper"="$val"
100104
done
101105
fi

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
"constructs>=10.0.0",
1010
]
1111

12-
install_requires: list[str] = []
12+
install_requires: list[str] = [
13+
"setuptools>=64",
14+
]
1315

1416
extras_require_test = [
1517
*aws_cdk_extras,

stack/stack.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,45 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
149149
self, "landsat_output_bucket", OUTPUT_BUCKET
150150
)
151151

152+
sentinel_input_bucket_expiration_days = int(
153+
os.environ["HLS_SENTINEL_INPUT_BUCKET_EXPIRATION_DAYS"]
154+
)
155+
152156
# Must be created as part of the stack due to trigger requirements
153157
self.sentinel_input_bucket = aws_s3.Bucket(
154158
self,
155159
"SentinelInputBucket",
156160
bucket_name=SENTINEL_INPUT_BUCKET,
157161
removal_policy=RemovalPolicy.DESTROY,
162+
lifecycle_rules=[
163+
# Setting expired_object_delete_marker cannot be done within a
164+
# lifecycle rule that also specifies expiration, expiration_date, or
165+
# tag_filters.
166+
aws_s3.LifecycleRule(expired_object_delete_marker=True),
167+
aws_s3.LifecycleRule(
168+
abort_incomplete_multipart_upload_after=Duration.days(1),
169+
expiration=Duration.days(sentinel_input_bucket_expiration_days),
170+
noncurrent_version_expiration=Duration.days(1),
171+
),
172+
],
158173
)
159174

160175
self.sentinel_input_bucket_historic = aws_s3.Bucket(
161176
self,
162177
"SentinelInputBucketHistoric",
163178
bucket_name=SENTINEL_INPUT_BUCKET_HISTORIC,
164179
removal_policy=RemovalPolicy.DESTROY,
180+
lifecycle_rules=[
181+
# Setting expired_object_delete_marker cannot be done within a
182+
# lifecycle rule that also specifies expiration, expiration_date, or
183+
# tag_filters.
184+
aws_s3.LifecycleRule(expired_object_delete_marker=True),
185+
aws_s3.LifecycleRule(
186+
abort_incomplete_multipart_upload_after=Duration.days(1),
187+
expiration=Duration.days(sentinel_input_bucket_expiration_days),
188+
noncurrent_version_expiration=Duration.days(1),
189+
),
190+
],
165191
)
166192

167193
self.landsat_input_bucket_historic = aws_s3.Bucket(
@@ -176,15 +202,25 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
176202
"LandsatIntermediateBucket",
177203
bucket_name=LANDSAT_INTERMEDIATE_OUTPUT_BUCKET,
178204
removal_policy=RemovalPolicy.DESTROY,
179-
lifecycle_rules=[aws_s3.LifecycleRule(expiration=Duration.days(60))],
205+
lifecycle_rules=[
206+
aws_s3.LifecycleRule(
207+
abort_incomplete_multipart_upload_after=Duration.days(1),
208+
expiration=Duration.days(60),
209+
)
210+
],
180211
)
181212

182213
self.gibs_intermediate_output_bucket = aws_s3.Bucket(
183214
self,
184215
"GibsIntermediateBucket",
185216
bucket_name=GIBS_INTERMEDIATE_OUTPUT_BUCKET,
186217
removal_policy=RemovalPolicy.DESTROY,
187-
lifecycle_rules=[aws_s3.LifecycleRule(expiration=Duration.days(60))],
218+
lifecycle_rules=[
219+
aws_s3.LifecycleRule(
220+
abort_incomplete_multipart_upload_after=Duration.days(1),
221+
expiration=Duration.days(60),
222+
)
223+
],
188224
)
189225

190226
self.efs = Efs(self, "Efs", network=self.network)

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extras = test
66
envdir = toxenv
77
passenv = AWS_DEFAULT_REGION
88
commands =
9-
pip install -e ./layers/hls_lambda_layer/python
9+
pip install --use-pep517 -e ./layers/hls_lambda_layer/python
1010
python -m pytest --cov=lambda_functions --ignore=node_modules --ignore=cdk.out
1111
flake8
1212

@@ -17,8 +17,8 @@ passenv =
1717
HLS_*
1818
AWS_*
1919
commands =
20-
nodeenv --node=20.17.0 --python-virtualenv
21-
npm install -g aws-cdk@v2.155.0
20+
nodeenv --node=lts --python-virtualenv
21+
npm install -g aws-cdk@v2.*
2222
cdk --version
2323

2424
[testenv:dev]

0 commit comments

Comments
 (0)