

Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 [AWS](https://github.com/awsdocs/aws-doc-sdk-examples)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# AWS SDKs AWS の料金表 を使用するためのコード例
<a name="pricing_code_examples"></a>

次のコード例は、 AWS Software Development Kit (SDK) AWS の料金表 で を使用する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

**その他のリソース**
+  **[AWS の料金表 ユーザーガイド](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html)** – 詳細については、「」を参照してください AWS の料金表。
+ **[AWS の料金表 API リファレンス](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/Welcome.html)** – 使用可能なすべての AWS の料金表 アクションに関する詳細。
+ **[AWS デベロッパーセンター](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23)** – カテゴリまたは全文検索でフィルタリングできるコード例。
+ **[AWS SDK の例](https://github.com/awsdocs/aws-doc-sdk-examples)** – 完全なコードを優先言語で含む GitHub リポジトリ。コードの設定と実行に関する説明が記載されています。

**Contents**
+ [基本](pricing_code_examples_basics.md)
  + [アクション](pricing_code_examples_actions.md)
    + [`DescribeServices`](pricing_example_pricing_DescribeServices_section.md)
    + [`GetAttributeValues`](pricing_example_pricing_GetAttributeValues_section.md)
    + [`GetProducts`](pricing_example_pricing_GetProducts_section.md)

# AWS SDKs AWS の料金表 を使用するための基本的な例
<a name="pricing_code_examples_basics"></a>

次のコード例は、 SDKs AWS の料金表 で AWS の基本を使用する方法を示しています。

**Contents**
+ [アクション](pricing_code_examples_actions.md)
  + [`DescribeServices`](pricing_example_pricing_DescribeServices_section.md)
  + [`GetAttributeValues`](pricing_example_pricing_GetAttributeValues_section.md)
  + [`GetProducts`](pricing_example_pricing_GetProducts_section.md)

# AWS SDKs AWS の料金表 を使用するためのアクション
<a name="pricing_code_examples_actions"></a>

次のコード例は、 AWS SDKs で個々の AWS の料金表 アクションを実行する方法を示しています。それぞれの例には、GitHub へのリンクがあり、そこにはコードの設定と実行に関する説明が記載されています。

 以下の例には、最も一般的に使用されるアクションのみ含まれています。詳細な一覧については、「[AWS の料金表 API リファレンス](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/Welcome.html)」を参照してください。

**Topics**
+ [`DescribeServices`](pricing_example_pricing_DescribeServices_section.md)
+ [`GetAttributeValues`](pricing_example_pricing_GetAttributeValues_section.md)
+ [`GetProducts`](pricing_example_pricing_GetProducts_section.md)

# CLI で `DescribeServices` を使用する
<a name="pricing_example_pricing_DescribeServices_section"></a>

次のサンプルコードは、`DescribeServices` を使用する方法を説明しています。

------
#### [ CLI ]

**AWS CLI**  
**サービスメタデータを取得するには**  
この例では、Amazon EC2 サービスコードのメタデータを取得します。  
コマンド:  

```
aws pricing describe-services --service-code AmazonEC2 --format-version aws_v1 --max-items 1
```
出力:  

```
{
  "Services": [
      {
          "ServiceCode": "AmazonEC2",
          "AttributeNames": [
              "volumeType",
              "maxIopsvolume",
              "instance",
              "instanceCapacity10xlarge",
              "locationType",
              "instanceFamily",
              "operatingSystem",
              "clockSpeed",
              "LeaseContractLength",
              "ecu",
              "networkPerformance",
              "instanceCapacity8xlarge",
              "group",
              "maxThroughputvolume",
              "gpuMemory",
              "ebsOptimized",
              "elasticGpuType",
              "maxVolumeSize",
              "gpu",
              "processorFeatures",
              "intelAvxAvailable",
              "instanceCapacity4xlarge",
              "servicecode",
              "groupDescription",
              "processorArchitecture",
              "physicalCores",
              "productFamily",
              "enhancedNetworkingSupported",
              "intelTurboAvailable",
              "memory",
              "dedicatedEbsThroughput",
              "vcpu",
              "OfferingClass",
              "instanceCapacityLarge",
              "capacitystatus",
              "termType",
              "storage",
              "intelAvx2Available",
              "storageMedia",
              "physicalProcessor",
              "provisioned",
              "servicename",
              "PurchaseOption",
              "instanceCapacity18xlarge",
              "instanceType",
              "tenancy",
              "usagetype",
              "normalizationSizeFactor",
              "instanceCapacity2xlarge",
              "instanceCapacity16xlarge",
              "maxIopsBurstPerformance",
              "instanceCapacity12xlarge",
              "instanceCapacity32xlarge",
              "instanceCapacityXlarge",
              "licenseModel",
              "currentGeneration",
              "preInstalledSw",
              "location",
              "instanceCapacity24xlarge",
              "instanceCapacity9xlarge",
              "instanceCapacityMedium",
              "operation"
          ]
      }
  ],
  "FormatVersion": "aws_v1"
}
```
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DescribeServices](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/pricing/describe-services.html)」を参照してください。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**例 1: us-east-1 リージョンで使用可能なすべてのサービスコードのメタデータを返します。**  

```
Get-PLSService -Region us-east-1
```
**出力:**  

```
AttributeNames                                                  ServiceCode
--------------                                                  -----------
{productFamily, servicecode, groupDescription, termType...}     AWSBudgets
{productFamily, servicecode, termType, usagetype...}            AWSCloudTrail
{productFamily, servicecode, termType, usagetype...}            AWSCodeCommit
{productFamily, servicecode, termType, usagetype...}            AWSCodeDeploy
{productFamily, servicecode, termType, usagetype...}            AWSCodePipeline
{productFamily, servicecode, termType, usagetype...}            AWSConfig
...
```
**例 2: us-east-1 リージョンの Amazon EC2 サービスのメタデータを返します。**  

```
Get-PLSService -ServiceCode AmazonEC2 -Region us-east-1
```
**出力:**  

```
AttributeNames                                                         ServiceCode
--------------                                                         -----------
{volumeType, maxIopsvolume, instanceCapacity10xlarge, locationType...} AmazonEC2
```
+  API の詳細については、「*AWS Tools for PowerShell コマンドレットリファレンス (V4)*」の「[DescribeServices](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**Tools for PowerShell V5**  
**例 1: us-east-1 リージョンで使用可能なすべてのサービスコードのメタデータを返します。**  

```
Get-PLSService -Region us-east-1
```
**出力:**  

```
AttributeNames                                                  ServiceCode
--------------                                                  -----------
{productFamily, servicecode, groupDescription, termType...}     AWSBudgets
{productFamily, servicecode, termType, usagetype...}            AWSCloudTrail
{productFamily, servicecode, termType, usagetype...}            AWSCodeCommit
{productFamily, servicecode, termType, usagetype...}            AWSCodeDeploy
{productFamily, servicecode, termType, usagetype...}            AWSCodePipeline
{productFamily, servicecode, termType, usagetype...}            AWSConfig
...
```
**例 2: us-east-1 リージョンの Amazon EC2 サービスのメタデータを返します。**  

```
Get-PLSService -ServiceCode AmazonEC2 -Region us-east-1
```
**出力:**  

```
AttributeNames                                                         ServiceCode
--------------                                                         -----------
{volumeType, maxIopsvolume, instanceCapacity10xlarge, locationType...} AmazonEC2
```
+  API の詳細については、「*AWS Tools for PowerShell コマンドレットリファレンス (V5)*」の「[DescribeServices](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

------

# CLI で `GetAttributeValues` を使用する
<a name="pricing_example_pricing_GetAttributeValues_section"></a>

次のサンプルコードは、`GetAttributeValues` を使用する方法を説明しています。

------
#### [ CLI ]

**AWS CLI**  
**属性値のリストを取得するには**  
次の `get-attribute-values` の例では、特定の属性で使用できる値のリストを取得します。  

```
aws pricing get-attribute-values \
    --service-code AmazonEC2 \
    --attribute-name volumeType \
    --max-items 2
```
出力:  

```
{
    "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==",
    "AttributeValues": [
        {
            "Value": "Cold HDD"
        },
        {
            "Value": "General Purpose"
        }
    ]
}
```
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetAttributeValues](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/pricing/get-attribute-values.html)」を参照してください。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**例 1: us-east-1 リージョンの Amazon EC2 の属性「volumeType」の値を返します。**  

```
Get-PLSAttributeValue -ServiceCode AmazonEC2 -AttributeName "volumeType" -region us-east-1
```
**出力:**  

```
Value
-----
Cold HDD
General Purpose
Magnetic
Provisioned IOPS
Throughput Optimized HDD
```
+  API の詳細については、「*AWS Tools for PowerShell コマンドレットリファレンス (V4)*」の「[GetAttributeValues](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**Tools for PowerShell V5**  
**例 1: us-east-1 リージョンの Amazon EC2 の属性「volumeType」の値を返します。**  

```
Get-PLSAttributeValue -ServiceCode AmazonEC2 -AttributeName "volumeType" -region us-east-1
```
**出力:**  

```
Value
-----
Cold HDD
General Purpose
Magnetic
Provisioned IOPS
Throughput Optimized HDD
```
+  API の詳細については、「*AWS Tools for PowerShell コマンドレットリファレンス (V5)*」の「[GetAttributeValues](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

------

# CLI で `GetProducts` を使用する
<a name="pricing_example_pricing_GetProducts_section"></a>

次のサンプルコードは、`GetProducts` を使用する方法を説明しています。

------
#### [ CLI ]

**AWS CLI**  
**製品のリストを取得するには**  
この例では、指定された条件に一致する製品のリストを取得します。  
コマンド:  

```
aws pricing get-products --filters file://filters.json --format-version aws_v1 --max-results 1 --service-code AmazonEC2
```
filters.json:  

```
        [
  {
    "Type": "TERM_MATCH",
    "Field": "ServiceCode",
    "Value": "AmazonEC2"
  },
  {
    "Type": "TERM_MATCH",
    "Field": "volumeType",
    "Value": "Provisioned IOPS"
  }
]
```
出力:  

```
{
  "FormatVersion": "aws_v1",
  "NextToken": "WGDY7ko8fQXdlaUZVdasFQ==:RVSagyIFn770XQOzdUIcO9BY6ucBG9itXAZGZF/zioUzOsUKh6PCcPWaOyPZRiMePb986TeoKYB9l55fw/CyoMq5ymnGmT1Vj39TljbbAlhcqnVfTmPIilx8Uy5bdDaBYy/e/2Ofw9Edzsykbs8LTBuNbiDQ+BBds5yeI9AQkUepruKk3aEahFPxJ55kx/zk",
  "PriceList": [
      "{\"product\":{\"productFamily\":\"Storage\",\"attributes\":{\"storageMedia\":\"SSD-backed\",\"maxThroughputvolume\":\"320 MB/sec\",\"volumeType\":\"Provisioned IOPS\",\"maxIopsvolume\":\"20000\",\"servicecode\":\"AmazonEC2\",\"usagetype\":\"APS1-EBS:VolumeUsage.piops\",\"locationType\":\"AWS Region\",\"location\":\"Asia Pacific (Singapore)\",\"servicename\":\"Amazon Elastic Compute Cloud\",\"maxVolumeSize\":\"16 TiB\",\"operation\":\"\"},\"sku\":\"3MKHN58N7RDDVGKJ\"},\"serviceCode\":\"AmazonEC2\",\"terms\":{\"OnDemand\":{\"3MKHN58N7RDDVGKJ.JRTCKXETXF\":{\"priceDimensions\":{\"3MKHN58N7RDDVGKJ.JRTCKXETXF.6YS6EN2CT7\":{\"unit\":\"GB-Mo\",\"endRange\":\"Inf\",\"description\":\"$0.138 per GB-month of Provisioned IOPS SSD (io1)  provisioned storage - Asia Pacific (Singapore)\",\"appliesTo\":[],\"rateCode\":\"3MKHN58N7RDDVGKJ.JRTCKXETXF.6YS6EN2CT7\",\"beginRange\":\"0\",\"pricePerUnit\":{\"USD\":\"0.1380000000\"}}},\"sku\":\"3MKHN58N7RDDVGKJ\",\"effectiveDate\":\"2018-08-01T00:00:00Z\",\"offerTermCode\":\"JRTCKXETXF\",\"termAttributes\":{}}}},\"version\":\"20180808005701\",\"publicationDate\":\"2018-08-08T00:57:01Z\"}"
  ]
}
```
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetProducts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/pricing/get-products.html)」を参照してください。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**例 1: Amazon EC2 のすべての製品の詳細を返します。**  

```
Get-PLSProduct -ServiceCode AmazonEC2 -Region us-east-1
```
**出力:**  

```
{"product":{"productFamily":"Compute Instance","attributes":{"enhancedNetworkingSupported":"Yes","memory":"30.5 GiB","dedicatedEbsThroughput":"800 Mbps","vcpu":"4","locationType":"AWS Region","storage":"EBS only","instanceFamily":"Memory optimized","operatingSystem":"SUSE","physicalProcessor":"Intel Xeon E5-2686 v4 (Broadwell)","clockSpeed":"2.3 GHz","ecu":"Variable","networkPerformance":"Up to 10 Gigabit","servicename":"Amazon Elastic Compute Cloud","instanceType":"r4.xlarge","tenancy":"Shared","usagetype":"USW2-BoxUsage:r4.xlarge","normalizationSizeFactor":"8","processorFeatures":"Intel AVX, Intel AVX2, Intel Turbo","servicecode":"AmazonEC2","licenseModel":"No License required","currentGeneration":"Yes","preInstalledSw":"NA","location":"US West (Oregon)","processorArchitecture":"64-bit","operation":"RunInstances:000g"},...
```
**例 2: us-east-1 リージョン内の Amazon EC2 のデータのうち、SSD ベースの「General Purpose」のボリュームタイプでフィルタリングされたデータを返します。**  

```
Get-PLSProduct -ServiceCode AmazonEC2 -Filter @{Type="TERM_MATCH";Field="volumeType";Value="General Purpose"},@{Type="TERM_MATCH";Field="storageMedia";Value="SSD-backed"} -Region us-east-1
```
**出力:**  

```
{"product":{"productFamily":"Storage","attributes":{"storageMedia":"SSD-backed","maxThroughputvolume":"160 MB/sec","volumeType":"General Purpose","maxIopsvolume":"10000",...
```
+  API の詳細については、「*AWS Tools for PowerShell コマンドレットリファレンス (V4)*」の「[GetProducts](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**Tools for PowerShell V5**  
**例 1: Amazon EC2 のすべての製品の詳細を返します。**  

```
Get-PLSProduct -ServiceCode AmazonEC2 -Region us-east-1
```
**出力:**  

```
{"product":{"productFamily":"Compute Instance","attributes":{"enhancedNetworkingSupported":"Yes","memory":"30.5 GiB","dedicatedEbsThroughput":"800 Mbps","vcpu":"4","locationType":"AWS Region","storage":"EBS only","instanceFamily":"Memory optimized","operatingSystem":"SUSE","physicalProcessor":"Intel Xeon E5-2686 v4 (Broadwell)","clockSpeed":"2.3 GHz","ecu":"Variable","networkPerformance":"Up to 10 Gigabit","servicename":"Amazon Elastic Compute Cloud","instanceType":"r4.xlarge","tenancy":"Shared","usagetype":"USW2-BoxUsage:r4.xlarge","normalizationSizeFactor":"8","processorFeatures":"Intel AVX, Intel AVX2, Intel Turbo","servicecode":"AmazonEC2","licenseModel":"No License required","currentGeneration":"Yes","preInstalledSw":"NA","location":"US West (Oregon)","processorArchitecture":"64-bit","operation":"RunInstances:000g"},...
```
**例 2: us-east-1 リージョン内の Amazon EC2 のデータのうち、SSD ベースの「General Purpose」のボリュームタイプでフィルタリングされたデータを返します。**  

```
Get-PLSProduct -ServiceCode AmazonEC2 -Filter @{Type="TERM_MATCH";Field="volumeType";Value="General Purpose"},@{Type="TERM_MATCH";Field="storageMedia";Value="SSD-backed"} -Region us-east-1
```
**出力:**  

```
{"product":{"productFamily":"Storage","attributes":{"storageMedia":"SSD-backed","maxThroughputvolume":"160 MB/sec","volumeType":"General Purpose","maxIopsvolume":"10000",...
```
+  API の詳細については、AWS Tools for PowerShell コマンドレットリファレンス (V5) の「[GetProducts](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。**

------