Amazon EC2定价api为每种类型的定价提供不同的属性,我如何知道我的ec2实例在哪个定价下运行。因为在定价api即json文件时,amazon提供的属性很少,并且在这些属性之外我只能从实例内部获取instanceType。如何获得其他人?
var titles: [String] = ["Title1", "Title2", "Title3"]
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
{
let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionViewCell
cell.titleLabel.text = self.titles[indexPath.row]
cell.subtitleLabel.text = "Choose to start"
cell.layer.cornerRadius = 10
return cell
}
答案 0 :(得分:0)
1)找到您的实例大小和AZ。例如
[ec2-user@ip-10-50-1-171 temp]$ ec2-metadata |grep placement
placement: eu-west-1a
[ec2-user@ip-10-50-1-171 temp]$ ec2-metadata |grep instance-type
instance-type: t2.micro
2)拉出正确的文件以获得EC2的定价,例如目前 https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/index.json
3)在此文件中有"产品"。因此,例如在产品中找到eu-west的t2.micro
"SYEPG42MVWFMUBT6" : {
"sku" : "SYEPG42MVWFMUBT6",
"productFamily" : "Compute Instance",
"attributes" : {
"servicecode" : "AmazonEC2",
"location" : "EU (Ireland)",
"locationType" : "AWS Region",
"instanceType" : "t2.micro",
"instanceFamily" : "General purpose",
"vcpu" : "1",
"physicalProcessor" : "Intel Xeon Family",
"clockSpeed" : "Up to 3.3 GHz",
"memory" : "1 GiB",
"storage" : "EBS only",
"networkPerformance" : "Low to Moderate",
"processorArchitecture" : "32-bit or 64-bit",
"tenancy" : "Shared",
"operatingSystem" : "SUSE",
"licenseModel" : "No License required",
"usagetype" : "EU-BoxUsage:t2.micro",
"operation" : "RunInstances:000g",
"preInstalledSw" : "NA",
"processorFeatures" : "Intel AVX; Intel Turbo"
}
},
请注意此产品的SKU
4)接下来找到"术语" json文件中的部分。有" OnDemand"的部分。和"保留"。 In" OnDemand"一次提到感兴趣的产品的SKU(在上面的示例中为SYEPG42MVWFMUBT6)。在"保留"有几个条目有不同的术语
如果您需要以编程方式执行所有这些步骤,则必须使用shell脚本和jq等工具或json处理库,如python中包含的那样