Skip to content

Commit 2713aad

Browse files
authored
feat: [sc-26323] Remove the use of AWS secret keys in NameGraph (#332)
* do not use auth in the s3 downloader * remove s3 keys from ci and dockerfile
1 parent ebe1a22 commit 2713aad

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ jobs:
2424
- name: build image
2525
run: |
2626
docker build \
27-
--build-arg AWS_SECRET_ACCESS_KEY \
28-
--build-arg AWS_ACCESS_KEY_ID \
2927
-t ${ECR_REPOSITORY}:commit_$(git rev-parse --short "$GITHUB_SHA") \
3028
-t ${ECR_REPOSITORY}:${PROD_IMAGE_TAG} \
3129
.

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ jobs:
3939
key: cache-v1.1
4040

4141
- name: Download data
42-
env:
43-
S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
44-
S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
4542
run: |
4643
ln -s ../tests/data/wikipedia2vec.pkl data/wikipedia2vec.pkl
4744
touch data/wikipedia2vec.pkl.vectors.npy

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ RUN poetry install --only main --no-root --no-interaction --no-ansi
1717
RUN poetry self add poetry-plugin-export
1818
RUN poetry export -f requirements.txt -o requirements.txt
1919

20-
ARG AWS_SECRET_ACCESS_KEY
21-
ARG AWS_ACCESS_KEY_ID
22-
2320
COPY data/ data
2421

2522
RUN mkdir namegraph

namegraph/download_from_s3.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,23 @@
44

55
import tarfile
66
import boto3
7+
import botocore
78
import hydra
89

9-
from dotenv import load_dotenv
1010
from omegaconf import DictConfig
1111

1212

1313
class S3Downloader:
1414
def __init__(self):
1515
self.s3_client = None
16+
self.region_name = 'us-east-1'
1617
self.bucket = 'prod-name-generator-namegeneratori-inputss3bucket-c26jqo3twfxy'
1718

1819
def get_client(self):
1920
if self.s3_client is None:
20-
load_dotenv()
21-
22-
S3_ACCESS_KEY_ID = os.getenv('S3_ACCESS_KEY_ID')
23-
S3_SECRET_ACCESS_KEY = os.getenv('S3_SECRET_ACCESS_KEY')
24-
REGION_NAME = 'us-east-1'
25-
self.s3_client = boto3.client('s3',
26-
aws_access_key_id=S3_ACCESS_KEY_ID,
27-
aws_secret_access_key=S3_SECRET_ACCESS_KEY,
28-
region_name=REGION_NAME
29-
)
30-
21+
self.s3_client = boto3.client(
22+
's3', region_name=self.region_name, config=botocore.config.Config(signature_version=botocore.UNSIGNED)
23+
)
3124
return self.s3_client
3225

3326
def download_file(self, url, path, override=True):

0 commit comments

Comments
 (0)