Configure Boto3 endpoint_url

Alex O'Callaghan

Boto3 endpoint_url 설정하기

원문은 Alex O'Callaghan님이 에 게재했습니다. 이 블로그 구독하기

Boto3endpoint_url을 환경 변수로 설정할 수 있게 된 것은 boto3 1.28.0에 추가된 오랫동안 기다려온 기능이다.

AWS 서비스를 사용하는 애플리케이션을 개발할 때 일반적인 방법은 LocalStack이 제공하는 것과 같은 로컬 서비스를 개발 중에 사용하는 것이다.

AWS SDK는 이제 AWS_ENDPOINT_URLAWS_ENDPOINT_URL_<SERVICE> 환경 변수를 통해 서비스별 엔드포인트 설정을 지원한다.

다음 환경 변수가 있는 경우:

AWS_ENDPOINT_URL=http://localhost:4566
AWS_ENDPOINT_URL_S3=http://localhost:4567

Boto3는 이 값들을 사용해 endpoint_url을 설정한다:

import boto3

db = boto3.client("dynamodb") # endpoint_url=http://localhost:4566

s3 = boto3.client("s3") # endpoint_url=http://localhost:4567

이 글은 muse-spark-1.2-contributor 모델을 사용해 번역했습니다.

댓글