Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- ebs 마운트
- 리눅스
- 테라폼 캐시
- 테라폼 맥
- MFA 분실
- Terrafrom
- 컨테이너 터미널
- 테라폼 자동완성
- AWS EBS
- 디스크 성능테스트
- docker 상태
- 텔레메트리란
- EBS 최적화
- 리눅스 시간대
- 컨테이너 터미널 로그아웃
- ebs 재부팅
- AWS
- Mac Terraform
- docker -i -t
- EBS
- 테라폼 설치
- 볼륨추가
- Authenticator
- xfs_quota
- /etc/fstab 설정
- 볼륨 연결
- EC2
- /etc/fstab 뜻
- MFA 인증
- epxress-generator
Archives
- Today
- Total
I got IT
AWS 인스턴스 타입별 가용영역 확인하기 본문
인스턴스 타입별로 지원되는 가용영역이 다르다.
이는 AWS 사업계획 및 물량 확보에 따라 달라질 수 있고
지원되는 가용영역에 해당 자원이 실제로 존재하는지 까지는 알 수 없다.
이에 대해 확인해 보려면 AWS 측에 문의하거나 Launch 해보는 수 밖에 없다.
인스턴스 타입별 지원되는 가용영역은 콘솔에서도 확인 가능하지만 아래와 같이 가용영역에 대한 정보만 출력하기 위한 코드를 작성했다.
코드는 AWS describe-instance-type-offerings API 기반의 boto3 라이브러를 활용해 작성했다.
Code
import boto3
import time
import pandas as pd
from datetime import datetime, timedelta, timezone
region = 'ap-northeast-2'
ec2 = boto3.client('ec2', region_name=region)
def getCurrentDateTime():
# Get current KST time
now = datetime.now(timezone(timedelta(hours=9)))
currentTime = now.strftime("%Y-%m-%d %H:%M:%S")
today = now.strftime("%Y-%m-%d")
return today
response = ec2.describe_instance_type_offerings(
DryRun=False,
LocationType='availability-zone',
Filters=[
{
'Name': 'location',
'Values': ['ap-northeast-2a', 'ap-northeast-2b', 'ap-northeast-2c','ap-northeast-2d']
},
],
)
offerings = response.get('InstanceTypeOfferings')
while("NextToken" in response):
response = ec2.describe_instance_type_offerings(
DryRun=False,
LocationType='availability-zone',
Filters=[
{
'Name': 'location',
'Values': ['ap-northeast-2a', 'ap-northeast-2b', 'ap-northeast-2c','ap-northeast-2d']
},
],
NextToken = response["NextToken"]
)
offerings.extend(response.get('InstanceTypeOfferings'))
# df 변환
df = pd.DataFrame(offerings)
df.drop(df.columns[1], axis=1, inplace=True)
df=df.sort_values(by='InstanceType')
# 엑셀로 저장
today = getCurrentDateTime()
fileName="InstanceOfferedAZ_"+today+".xlsx"
df.to_excel(fileName, index=False)
print(f"엑셀 파일로 변환 완료: {fileName}")
※ 참고
기본적으로 위 코드를 실행하기 위해서는 EC2 > DescribeInstanceTypeOfferings 액션에 대한 권한이 있어야한다.
'AWS' 카테고리의 다른 글
EKS 스토리지 - Stateful 애플리케이션 구성(with PV) (0) | 2025.02.23 |
---|---|
AWS EBS 성능테스트 (0) | 2023.08.14 |
AWS EBS 재부팅 시 자동 마운트 설정 (0) | 2023.06.04 |
AWS 계정 MFA 분실 및 재활성 가이드 (0) | 2023.05.22 |
AWS EBS 연결 및 마운트 과정 (0) | 2023.05.18 |