

Ada lebih banyak contoh AWS SDK yang tersedia di repo Contoh [SDK AWS Doc](https://github.com/awsdocs/aws-doc-sdk-examples). GitHub 

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

# Contoh kode untuk Daftar Harga AWS menggunakan AWS SDKs
<a name="pricing_code_examples"></a>

Contoh kode berikut menunjukkan cara menggunakan Daftar Harga AWS kit pengembangan AWS perangkat lunak (SDK).

*Tindakan* merupakan kutipan kode dari program yang lebih besar dan harus dijalankan dalam konteks. Sementara tindakan menunjukkan cara memanggil fungsi layanan individual, Anda dapat melihat tindakan dalam konteks dalam skenario terkait.

**Sumber daya lainnya**
+  **[Daftar Harga AWS Panduan Pengguna](https://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html)** — Informasi lebih lanjut tentang Daftar Harga AWS.
+ **[Daftar Harga AWS Referensi API](https://docs.aws.amazon.com/aws-cost-management/latest/APIReference/Welcome.html)** — Detail tentang semua Daftar Harga AWS tindakan yang tersedia.
+ **[AWS Pusat Pengembang](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23)** - Contoh kode yang dapat Anda filter berdasarkan kategori atau pencarian teks lengkap.
+ **[AWS Contoh SDK](https://github.com/awsdocs/aws-doc-sdk-examples)** — GitHub repo dengan kode lengkap dalam bahasa pilihan. Termasuk instruksi untuk mengatur dan menjalankan kode.

**Contents**
+ [Hal-hal mendasar](pricing_code_examples_basics.md)
  + [Tindakan](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)

# Contoh dasar untuk Daftar Harga AWS menggunakan AWS SDKs
<a name="pricing_code_examples_basics"></a>

Contoh kode berikut menunjukkan cara menggunakan dasar-dasar Daftar Harga AWS dengan AWS SDKs. 

**Contents**
+ [Tindakan](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)

# Tindakan untuk Daftar Harga AWS menggunakan AWS SDKs
<a name="pricing_code_examples_actions"></a>

Contoh kode berikut menunjukkan bagaimana melakukan Daftar Harga AWS tindakan individu dengan AWS SDKs. Setiap contoh menyertakan tautan ke GitHub, di mana Anda dapat menemukan instruksi untuk mengatur dan menjalankan kode. 

 Contoh berikut hanya mencakup tindakan yang paling umum digunakan. Untuk daftar lengkapnya, lihat [Referensi Daftar Harga 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)

# Gunakan `DescribeServices` dengan CLI
<a name="pricing_example_pricing_DescribeServices_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`DescribeServices`.

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

**AWS CLI**  
**Untuk mengambil metadata layanan**  
Contoh ini mengambil metadata untuk kode layanan Amazon EC2.  
Perintah:  

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

```
{
  "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"
}
```
+  Untuk detail API, lihat [DescribeServices](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/pricing/describe-services.html)di *Referensi AWS CLI Perintah*. 

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

**Alat untuk PowerShell V4**  
**Contoh 1: Mengembalikan metadata untuk semua kode layanan yang tersedia di wilayah us-east-1.**  

```
Get-PLSService -Region us-east-1
```
**Output:**  

```
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
...
```
**Contoh 2: Mengembalikan metadata untuk layanan Amazon EC2 di wilayah us-east-1.**  

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

```
AttributeNames                                                         ServiceCode
--------------                                                         -----------
{volumeType, maxIopsvolume, instanceCapacity10xlarge, locationType...} AmazonEC2
```
+  Untuk detail API, lihat [DescribeServices](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan metadata untuk semua kode layanan yang tersedia di wilayah us-east-1.**  

```
Get-PLSService -Region us-east-1
```
**Output:**  

```
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
...
```
**Contoh 2: Mengembalikan metadata untuk layanan Amazon EC2 di wilayah us-east-1.**  

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

```
AttributeNames                                                         ServiceCode
--------------                                                         -----------
{volumeType, maxIopsvolume, instanceCapacity10xlarge, locationType...} AmazonEC2
```
+  Untuk detail API, lihat [DescribeServices](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `GetAttributeValues` dengan CLI
<a name="pricing_example_pricing_GetAttributeValues_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`GetAttributeValues`.

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

**AWS CLI**  
**Untuk mengambil daftar nilai atribut**  
`get-attribute-values`Contoh berikut mengambil daftar nilai yang tersedia untuk atribut yang diberikan.  

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

```
{
    "NextToken": "eyJOZXh0VG9rZW4iOiBudWxsLCAiYm90b190cnVuY2F0ZV9hbW91bnQiOiAyfQ==",
    "AttributeValues": [
        {
            "Value": "Cold HDD"
        },
        {
            "Value": "General Purpose"
        }
    ]
}
```
+  Untuk detail API, lihat [GetAttributeValues](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/pricing/get-attribute-values.html)di *Referensi AWS CLI Perintah*. 

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

**Alat untuk PowerShell V4**  
**Contoh 1: Mengembalikan nilai untuk atribut 'VolumeType' untuk Amazon EC2 di wilayah us-east-1.**  

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

```
Value
-----
Cold HDD
General Purpose
Magnetic
Provisioned IOPS
Throughput Optimized HDD
```
+  Untuk detail API, lihat [GetAttributeValues](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan nilai untuk atribut 'VolumeType' untuk Amazon EC2 di wilayah us-east-1.**  

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

```
Value
-----
Cold HDD
General Purpose
Magnetic
Provisioned IOPS
Throughput Optimized HDD
```
+  Untuk detail API, lihat [GetAttributeValues](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------

# Gunakan `GetProducts` dengan CLI
<a name="pricing_example_pricing_GetProducts_section"></a>

Contoh kode berikut menunjukkan cara menggunakan`GetProducts`.

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

**AWS CLI**  
**Untuk mengambil daftar produk**  
Contoh ini mengambil daftar produk yang cocok dengan kriteria yang diberikan.  
Perintah:  

```
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"
  }
]
```
Output:  

```
{
  "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\"}"
  ]
}
```
+  Untuk detail API, lihat [GetProducts](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/pricing/get-products.html)di *Referensi AWS CLI Perintah*. 

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

**Alat untuk PowerShell V4**  
**Contoh 1: Mengembalikan detail semua produk untuk Amazon EC2.**  

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

```
{"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"},...
```
**Contoh 2: Mengembalikan data untuk Amazon EC2 di wilayah us-east-1 yang difilter berdasarkan jenis volume 'Tujuan Umum' yang didukung SSD.**  

```
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
```
**Output:**  

```
{"product":{"productFamily":"Storage","attributes":{"storageMedia":"SSD-backed","maxThroughputvolume":"160 MB/sec","volumeType":"General Purpose","maxIopsvolume":"10000",...
```
+  Untuk detail API, lihat [GetProducts](https://docs.aws.amazon.com/powershell/v4/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V4)*. 

**Alat untuk PowerShell V5**  
**Contoh 1: Mengembalikan detail semua produk untuk Amazon EC2.**  

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

```
{"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"},...
```
**Contoh 2: Mengembalikan data untuk Amazon EC2 di wilayah us-east-1 yang difilter berdasarkan jenis volume 'Tujuan Umum' yang didukung SSD.**  

```
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
```
**Output:**  

```
{"product":{"productFamily":"Storage","attributes":{"storageMedia":"SSD-backed","maxThroughputvolume":"160 MB/sec","volumeType":"General Purpose","maxIopsvolume":"10000",...
```
+  Untuk detail API, lihat [GetProducts](https://docs.aws.amazon.com/powershell/v5/reference)di *Referensi Alat AWS untuk PowerShell Cmdlet (V5)*. 

------