例: 1 year partial upfront, Compute, instanceType: t3.medium, のper hourから「時間単位のコミットメント」、「一部前払い金」を計算する。
profile=example
# durationsを指定して、offeringIdを取得。describe-savings-plans-offering-ratesではdurationsで絞り込めない。
aws savingsplans describe-savings-plans-offerings \
--product-type EC2 \
--plan-types Compute \
--payment-options "Partial Upfront" \
--durations $((3600*24*365)) \
--currencies USD \
--profile $profile
{
"searchResults": [
{
"offeringId": "8a5f1067-1eba-46cd-804c-4eb74c0fd43b",
"productTypes": [
"Fargate",
"EC2",
"Lambda"
],
"planType": "Compute",
"description": "1 year Partial Upfront Compute Savings Plan",
"paymentOption": "Partial Upfront",
"durationSeconds": 31536000,
"currency": "USD",
"serviceCode": "ComputeSavingsPlans",
"usageType": "ComputeSP:1yrPartialUpfront",
"operation": "",
"properties": []
}
],
"nextToken": "11111114011AKXHi82LDrvXSYuU4NaQhgqffGWGkm7NYgDgGhZp2asyvYVUZFiQNU1YBhoBJF"
}
# 検索したいリージョン、インスタンスタイプ
region=ap-northeast-1
instanceType=t3.medium
# durationSeconds: 1年
# usageType: BoxUsage のみ
aws savingsplans describe-savings-plans-offering-rates \
--savings-plan-payment-options "Partial Upfront" \
--products EC2 \
--savings-plan-types Compute \
--operations RunInstances \
--filters "name=region,values=$region" "name=instanceType,values=$instanceType" "name=tenancy,values=shared" \
--profile $profile \
| jq '.searchResults[] | select(.savingsPlanOffering.durationSeconds == '$((3600*24*365))') | select(.usageType | contains("BoxUsage"))'
{
"savingsPlanOffering": {
"offeringId": "8a5f1067-1eba-46cd-804c-4eb74c0fd43b",
"paymentOption": "Partial Upfront",
"planType": "Compute",
"durationSeconds": 31536000,
"currency": "USD",
"planDescription": "1 year Partial Upfront Compute Savings Plan"
},
"rate": "0.0407",
"unit": "Hrs",
"productType": "EC2",
"serviceCode": "AmazonEC2",
"usageType": "APN1-BoxUsage:t3.medium",
"operation": "RunInstances",
"properties": [
{
"name": "instanceFamily",
"value": "t3"
},
{
"name": "productDescription",
"value": "Linux/UNIX"
},
{
"name": "instanceType",
"value": "t3.medium"
},
{
"name": "tenancy",
"value": "shared"
},
{
"name": "region",
"value": "ap-northeast-1"
}
]
}