code: def get_ebs_metadata(pricing):
      storage_mapping = {}
  
      for _, product in pricing["products"].items():
          if product.get("attributes") is None:
              continue
          if product.get("productFamily") != "Storage":
              continue
          # ignore legacy standard storage
          if product["attributes"].get("volumeApiName") == "standard":
              continue
  
          price_dimensions = list(
              pricing["terms"]["OnDemand"][product["sku"]].values()
          )[0]["priceDimensions"]
          price = list(price_dimensions.values())[0]["pricePerUnit"][
              "USD"
          ]
  
          metadata = {
              "type": product["attributes"].get("volumeApiName"),
              "price_gb": float(price),
          }
  
          # io1 has per IOPS pricing --> add pricing to metadata
          # if storagedevice does not price per IOPS will set value to 0
          if product["attributes"].get("volumeApiName") == "io1":
              # go through pricing data until found data about IOPS pricing
              for _, product_iops in pricing["products"].items():
                  if product_iops.get("attributes") is None:
                      continue
                  if (
                      product_iops.get("productFamily")
                      != "System Operation"
                  ):
                      continue
                  if (
                      product_iops["attributes"].get("volumeApiName")
                      != "io1"
                  ):
                      continue
                  if (
                      product_iops["attributes"].get("group")
                      != "EBS IOPS"
                  ):
                      continue
                  if (
                      product_iops["attributes"].get("provisioned")
                      != "Yes"
                  ):
                      continue
  
                  price_dimensions = list(
                      pricing["terms"]["OnDemand"][
                          product_iops["sku"]
                      ].values()
                  )[0]["priceDimensions"]
                  price = list(price_dimensions.values())[0][
                      "pricePerUnit"
                  ]["USD"]
  
                  metadata["price_iops"] = price
                  metadata["price_throughput"] = 0
                  metadata["iops_configurable"] = "true"
                  metadata["throughput_configurable"] = "false"
  
          elif product["attributes"].get("volumeApiName") == "gp3":
              # go through pricing data until found data about IOPS and throughput pricing
              for _, product_iops in pricing["products"].items():
                  if product_iops.get("attributes") is None:
                      continue
                  if product_iops.get("productFamily") not in [
                      "System Operation",
                      "Provisioned Throughput",
                  ]:
                      continue
                  if (
                      product_iops["attributes"].get("volumeApiName")
                      != "gp3"
                  ):
                      continue
                  if product_iops["attributes"].get("group") not in [
                      "EBS IOPS",
                      "EBS Throughput",
                  ]:
                      continue
                  if (
                      product_iops["attributes"].get("provisioned")
                      != "Yes"
                  ):
                      continue
  
                  price_dimensions = list(
                      pricing["terms"]["OnDemand"][
                          product_iops["sku"]
                      ].values()
                  )[0]["priceDimensions"]
                  if (
                      product_iops["attributes"].get("group")
                      == "EBS IOPS"
                  ):
                      price_iops = list(price_dimensions.values())[0][
                          "pricePerUnit"
                      ]["USD"]
                  else:
                      price_throughput = (
                          float(
                              list(price_dimensions.values())[0][
                                  "pricePerUnit"
                              ]["USD"]
                          )
                          / 1000
                      )
  
              metadata["price_iops"] = price_iops
              metadata["price_throughput"] = price_throughput
              metadata["throughput_configurable"] = "true"
              metadata["iops_configurable"] = "true"
  
          # set default values for all other storage types
          else:
              metadata["price_iops"] = 0
              metadata["price_throughput"] = 0
              metadata["iops_configurable"] = "false"
              metadata["throughput_configurable"] = "false"
  
          storage_mapping[
              product["attributes"]["volumeApiName"]
          ] = metadata
  
      return storage_mapping
  
file_path: cortex/pkg/lib/aws/gen_resource_metadata.py
imports: import requests
  import re
  from string import Template
label_desc: Use image node_id 5 for calling a global function with example usage: get_ebs_metadata(pricing) and returns: storage_mapping