AWS 價格表 使用 Tools for PowerShell V5 的範例 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

AWS 價格表 使用 Tools for PowerShell V5 的範例

下列程式碼範例示範如何使用 AWS Tools for PowerShell V5 搭配 來執行動作和實作常見案例 AWS 價格表。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

以下程式碼範例顯示如何使用 Get-PLSAttributeValue

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 《 Cmdlet Reference (V5)》中的 GetAttributeValues

以下程式碼範例顯示如何使用 Get-PLSProduct

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 後端。

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 詳細資訊,請參閱《 Cmdlet 參考》中的 GetProducts (V5)。 AWS Tools for PowerShell

以下程式碼範例顯示如何使用 Get-PLSService

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 Cmdlet 參考 (V5) 中的 DescribeServices