AWS 价目表 使用工具的示例 PowerShell - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

AWS 价目表 使用工具的示例 PowerShell

以下代码示例向您展示了如何使用with来执行操作和实现常见场景 AWS 价目表。 AWS Tools for PowerShell

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示如何使用 Get-PLSAttributeValue

用于 PowerShell

示例 1:返回 us-east-1 区域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 参考GetAttributeValues中的。

以下代码示例演示如何使用 Get-PLSProduct

用于 PowerShell

示例 1:亚马逊所有商品的退货详情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:返回按支持的 “EC2通用型” 卷类型筛选的 us-east-1 区域的亚马逊数据。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详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考GetProducts中的。

以下代码示例演示如何使用 Get-PLSService

用于 PowerShell

示例 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 EC2 区域中亚马逊服务的元数据。

Get-PLSService -ServiceCode AmazonEC2 -Region us-east-1

输出:

AttributeNames ServiceCode -------------- ----------- {volumeType, maxIopsvolume, instanceCapacity10xlarge, locationType...} AmazonEC2
  • 有关API详细信息,请参阅 AWS Tools for PowerShell Cmdlet 参考DescribeServices中的。