헤더
import boto3
리소스 가져오기
## 'ap-northeast'는 'seoul region' 을 의미한다.
s3_resource = boto3.client('s3', 'ap-northeast-2')
response = s3_resource.list_buckets()
계정 내에 존재하는 버킷 리스트 출력
print("계정 내의 S3 버킷 리스트")
for bucket in response['Buckets']:
print(f'{bucket["Name"]}')
Output:
계정 내의 S3 버킷 리스트
aws-glue-assets-539388690341-ap-northeast-2
dataeng-clean-zone-hanium
dataeng-landing-zone-hanium
hanium-trustworthyai-sources
itv-flights-2016
mass-shooting-athena
sagemaker-ap-northeast-1-539388690341
sagemaker-studio-539388690341-481jja1sjok
sagemaker-studio-539388690341-u2k7k0dbae
boto3.client('s3').list_buckets()
를 출력해보면 다음과 같은 필드를 얻을 수 있다.
{
"ResponseMetadata": {
"RequestId": "A3P5SA28ZNXRXHTE",
"HostId": "J/+Z3CtQVjVqspi7x+KYUdscAA0uIkfFBfdHTV+Rv9gJPmzac2CZeVQVIIh8k/Pgm+bSfCpzWz4=",
"HTTPStatusCode": 200,
"HTTPHeaders": {
"x-amz-id-2": "J/+Z3CtQVjVqspi7x+KYUdscAA0uIkfFBfdHTV+Rv9gJPmzac2CZeVQVIIh8k/Pgm+bSfCpzWz4=",
"x-amz-request-id": "A3P5SA28ZNXRXHTE",
"date": "Wed, 07 Sep 2022 12:12:00 GMT",
"content-type": "application/xml",
"transfer-encoding": "chunked",
"server": "AmazonS3"
},
"RetryAttempts": 0
},
"Buckets": [
{
"Name": "aws-glue-assets-539388690341-ap-northeast-2",
"CreationDate": "2022-07-07 03:18:43+00:00"
},
{
"Name": "dataeng-clean-zone",
"CreationDate": "2022-08-25 18:47:15+00:00"
},
{
...
"Owner": {
"ID": "f6ab8c78aba1c3a39c22ab469cvee113f2fc1c029fe123429230b0df4077d5e2d"
}
}
boto3.client('s3').list_buckets()['Buckets']
값을 살펴보면, 다시 Name
과 CreationDate
로 나눠지는 모습을 확인할 수 있다.
이때, CreationDate의 시간 형식(tzinfo)는 tzutc
형식을 따른다.
2019-10-25 15:33:27.388853+0000 와 같은 형식을 tzutc time format이라고 한다.
'DevOps > Cloud Service' 카테고리의 다른 글
[SageMaker studio] Data Wrangler flow (0) | 2022.09.08 |
---|---|
[Boto3] S3 bucket 생성 (0) | 2022.09.07 |
awscli 1.25.17 requires botocore==1.27.17, but you have botocore 1.27.66 which is incompatible. (0) | 2022.09.06 |
[네이버 클라우드] 서버 생성 및 접근 (0) | 2022.05.28 |