EC2の価格を取得するプログラムを作成したのですが、
t2.nanoの価格が0.0000000000で返ってきます。
その他のタイプのインスタンス料金は正しく取れています。
原因が分からず困っています。
PHP
1// オンデマンド インスタンスタイプの価格を取得 2 function getPrice($InstanceType,$platform,$region_name){ 3 $client = new PricingClient([ 4 'region' => 'us-east-1', 5 'version'=> 'latest' 6 ]); 7 8 $result = $client->getProducts([ 9 'Filters' => [ 10 [ 11 'Field' => 'instanceType', 12 'Type' => 'TERM_MATCH', 13 'Value' => $InstanceType, 14 ], 15 [ 16 'Field' => 'operatingSystem', 17 'Type' => 'TERM_MATCH', 18 'Value' => $platform, 19 ], 20 [ 21 'Field' => 'location', 22 'Type' => 'TERM_MATCH', 23 'Value' => $region_name, 24 ], 25 [ 26 'Field' => 'currentGeneration', 27 'Type' => 'TERM_MATCH', 28 'Value' =>'Yes' 29 ], 30 [ 31 'Field' => 'instanceFamily', 32 'Type' => 'TERM_MATCH', 33 'Value' => 'General purpose' 34 ], 35 [ 36 'Field' => 'tenancy', 37 'Type' => 'TERM_MATCH', 38 'Value' => 'Shared' 39 ], 40 [ 41 'Field' => 'preInstalledSw', 42 'Type' => 'TERM_MATCH', 43 'Value' => 'NA' 44 ], 45 [ 46 'Field' => 'licenseModel', 47 'Type' => 'TERM_MATCH', 48 'Value' => 'No License required' 49 ], 50 ], 51 'FormatVersion' => 'aws_v1', 52 'MaxResults' => 1, 53 'ServiceCode' =>'AmazonEC2', 54 ]); 55 56 57 $PriceList = $result['PriceList']; 58 $comma_separated = implode(",", $PriceList); 59 $decode_data = json_decode($comma_separated, true); 60 $OnDemand = $decode_data['terms']['OnDemand']; 61 $OnDemand_keys = implode(",", array_keys($OnDemand)); 62 $priceDimensions= $OnDemand[$OnDemand_keys]['priceDimensions']; 63 $priceDimensions_keys = implode(",", array_keys($priceDimensions)); 64 $pricePerUnit= $priceDimensions[$priceDimensions_keys]['pricePerUnit']['USD']; 65 return $pricePerUnit; 66 }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。