본문 바로가기
WIKI 기술 지식 베이스

lakeFS와 AWS CLI 함께 사용하기

원문 보기 위키 갱신

lakeFS는 S3 호환 API를 제공해요. 그래서 AWS S3 CLI로 lakeFS 저장소의 오브젝트에 직접 접근할 수 있어요. AWS 프로파일을 lakeFS용으로 만들어 두면 일상적인 S3 워크플로를 그대로 재사용할 수 있어요.

출처: 문서

본문

lakeFS는 S3 호환 API를 노출해요. 그래서 AWS S3 CLI를 사용해 저장소 안의 오브젝트와 상호작용할 수 있어요.

설정

lakeFS용 AWS 프로파일을 만들어 두면 좋아요.

lakeFS 자격 증명을 설정하려면 다음을 실행해요:

aws configure --profile lakefs

AWS Access Key ID와 AWS Secret Access Key를 입력하라는 프롬프트가 뜰 거예요.

대략 이런 모습이에요:

aws configure --profile lakefs
# output:
# AWS Access Key ID [None]: «redacted:AKIA…»
# AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
# Default region name [None]:
# Default output format [None]:

경로 규칙

S3에서 오브젝트에 접근할 때는 lakeFS의 경로 규칙을 사용해야 해요:

s3://[REPOSITORY]/[BRANCH]/PATH/TO/OBJECT

사용 방법

자격 증명을 설정한 뒤에는 명령이 대략 이런 모습이 돼요:

aws s3 --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    ls s3://example-repo/main/example-directory

별칭(alias)을 만들면 더 짧고 편하게 쓸 수 있어요.

예제

디렉터리 목록 보기

aws --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    s3 ls s3://example-repo/main/example-directory

lakeFS에서 lakeFS로 복사

aws --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    s3 cp s3://example-repo/main/example-file-1 s3://example-repo/main/example-file-2

lakeFS에서 로컬 경로로 복사

aws --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    s3 cp s3://example-repo/main/example-file-1 /path/to/local/file

로컬 경로에서 lakeFS로 복사

aws --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    s3 cp /path/to/local/file s3://example-repo/main/example-file-1

파일 삭제

aws --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    s3 rm s3://example-repo/main/example-directory/example-file

디렉터리 삭제

aws --profile lakefs \
    --endpoint-url https://lakefs.example.com \
    s3 rm s3://example-repo/main/example-directory/ --recursive

별칭 추가

명령을 더 짧고 편하게 만들려면 별칭을 만들 수 있어요:

alias awslfs='aws --endpoint https://lakefs.example.com --profile lakefs'

이제 별칭을 사용한 ls 명령은 다음과 같아져요:

awslfs s3 ls s3://example-repo/main/example-directory

더 알아보기 (Learn more)

공식 문서의 자세한 내용은 https://docs.lakefs.io/reference/aws-cli/에서 확인하실 수 있어요.