

# AWS CLI를 사용한 AWS 가격표 예시
<a name="cli_pricing_code_examples"></a>

다음 코드 예시는 AWS 가격표와 함께 AWS Command Line Interface를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

*작업*은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 직접적으로 호출하는 방법을 보여주며 관련 시나리오의 컨텍스트에 맞는 작업을 볼 수 있습니다.

각 예시에는 전체 소스 코드에 대한 링크가 포함되어 있으며, 여기에서 컨텍스트에 맞춰 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있습니다.

**Topics**
+ [작업](#actions)

## 작업
<a name="actions"></a>

### `describe-services`
<a name="pricing_DescribeServices_cli_topic"></a>

다음 코드 예시에서는 `describe-services`의 사용 방법을 보여줍니다.

**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)를 참조하세요.

### `get-attribute-values`
<a name="pricing_GetAttributeValues_cli_topic"></a>

다음 코드 예시에서는 `get-attribute-values`의 사용 방법을 보여줍니다.

**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)를 참조하세요.

### `get-products`
<a name="pricing_GetProducts_cli_topic"></a>

다음 코드 예시에서는 `get-products`의 사용 방법을 보여줍니다.

**AWS CLI**  
**제품 목록 가져오기**  
이 예시에서는 지정된 기준과 일치하는 제품 목록을 가져옵니다.  
명령:  

```
aws pricing get-products --filters file://filters.json --format-version aws_v1 --max-results 1 --service-code AmazonEC2
```
filter.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)를 참조하세요.