Skip to content

Commit ef519c3

Browse files
authored
Requester Pay (#90)
* /deploy sit * /deploy sit * /deploy sit * /deploy sit * /deploy sit * update changelog
1 parent 1e034eb commit ef519c3

6 files changed

Lines changed: 968 additions & 607 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ jobs:
7575
7676
# Version calculation based on branch
7777
if [[ "${{ github.ref }}" =~ ^refs/heads/(issue|feature|dependabot)/ ]]; then
78-
new_version="${base_version%%-*}+$(git rev-parse --short HEAD)"
78+
TIMESTAMP=$(date -u +"%Y%m%d%H%M")
79+
new_version="${base_version}a${TIMESTAMP}"
7980
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV
8081
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
8182
echo "TARGET_ENV_UPPERCASE=SIT" >> $GITHUB_ENV

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [Unreleased]
88

99
### Added
10+
- Added in requester pay flag into s3 calls
1011
### Changed
1112
### Deprecated
1213
### Removed

docker/lambdaDockerfileArm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ FROM public.ecr.aws/lambda/python:3.10-arm64
66
ARG SOURCE
77
ARG DIST_PATH
88

9-
RUN yum -q -y install gcc
9+
# Install compilers needed for matplotlib (C + C++)
10+
RUN yum -q -y install gcc gcc-c++ make
1011

1112
# Create function directory
1213
# RUN mkdir -p ${FUNCTION_DIR}

podaac/lambda_handler/lambda_handler.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ def clean_all(self):
101101
rmtree(self.path)
102102
clean_tmp()
103103

104+
def _get_s3_extra(self, upload=False):
105+
"""Helper to build the extra dict for S3 operations."""
106+
extra = {"ACL": "bucket-owner-full-control"} if upload else {}
107+
if self.config.get("requester_pay", False):
108+
extra["RequestPayer"] = "requester"
109+
return extra
110+
104111
def download_file_from_s3(self, s3file, working_dir):
105112
""" Download s3 file to local
106113
@@ -117,7 +124,8 @@ def download_file_from_s3(self, s3file, working_dir):
117124
full path of the downloaded file
118125
"""
119126
try:
120-
return s3.download(s3file, working_dir)
127+
extra = self._get_s3_extra()
128+
return s3.download(s3file, working_dir, extra=extra)
121129
except botocore.exceptions.ClientError as ex:
122130
self.logger.error("Error downloading file %s: %s" % (s3file, working_dir), exc_info=True)
123131
raise ex
@@ -133,7 +141,8 @@ def upload_file_to_s3(self, filename, uri):
133141
s3 string of file location
134142
"""
135143
try:
136-
return s3.upload(filename, uri, extra={"ACL": "bucket-owner-full-control"})
144+
extra = self._get_s3_extra(upload=True)
145+
return s3.upload(filename, uri, extra=extra)
137146
except botocore.exceptions.ClientError as ex:
138147
self.logger.error("Error uploading file %s: %s" % (os.path.basename(os.path.basename(filename)), str(ex)), exc_info=True)
139148
raise ex
@@ -370,7 +379,8 @@ def _download_file(self, file_):
370379
"""Download the input file from S3."""
371380
input_file = f's3://{file_["bucket"]}/{file_["key"]}'
372381
try:
373-
return s3.download(input_file, path=self.path)
382+
extra = self._get_s3_extra()
383+
return s3.download(input_file, path=self.path, extra=extra)
374384
except botocore.exceptions.ClientError as ex:
375385
self.logger.error("Error downloading file from S3: {}".format(ex), exc_info=True)
376386
raise

0 commit comments

Comments
 (0)