AWS Marketplace

How to meter usage for subscriptions when using SaaS Quick Start

AWS Marketplace now enables sellers, Independent Software Vendors (ISVs), and Consulting Partners (CPs) to complete the AWS Marketplace SaaS product API integration in as little as 10 minutes using SaaS Quick Start.

In this blog post, I will show how to meter usage for both subscriptions and contract with  consumption while using SaaS Quick Start.

For SaaS subscriptions listings, the SaaS seller must meter for all usage and report the metering record to AWS Marketplace. For SaaS Contract with Consumption, the seller only meters for usage beyond a customer’s contract entitlements. Through this blog post, I will show sellers how to meter usage when using SaaS Quick Start.

Prerequisites

To meter usage for SaaS Subscription and Contract with Consumption using the SaaS Quick Start, you must complete the following prerequisites:

  1. Fully register with AWS Marketplace as a seller.
  2. You must have used the AWS Marketplace Quick Start to setup a simplified integration for your SaaS offering.
  3. Obtain your CustomerIdentifier. This is used to identify an individual customer in your application. To obtain your customer identifier, do the following:
    1. After running the SaaS Quick Start Solution, open the AWS CloudFormation console at https://console.aws.amazon.com/cloudformation.
    2. Select the nested SaaS Quick Start stack that was created by running the SaaS Quick Start Solution.
    3. Select the Resources tab and then search for the AWSMarketplaceSubscribers
    4. Select Explore table items and then copy the CustomerIdentifier.

How to meter usage when using SaaS Quick Start

To meter usage, follow these steps:

  1. Insert the record in the AWSMarketplaceMeteringRecords table using the following steps:
    1. Create a JSON file with the following format on your local system:

{

  "create_timestamp": {

    "N": "113123"

  },

  "customerIdentifier": {

    "S": "ifAPi5AcF3"

  },

  "dimension_usage": {

    "L": [

      {

        "M": {

          "dimension": {

            "S": "users"

          },

          "value": {

            "N": "3"

          }

        }

      },

      {

        "M": {

          "dimension": {

            "S": "admin_users"

          },

          "value": {

            "N": "1"

          }

        }

      }

    ]

  },

  "metering_pending": {

    "S": "true"

  }

}

    1. In the JSON file you created in step 1.1, replace the following four values with the following:
      • create_timestamp – The accepted time stamp is UNIX timestamp in UTC time
      • customerIdentifier – Paste the value of the customer identifier from Prerequisite step 3.4.
      • dimension – The API key of the dimension with a value.
  1. Copy the file you created in steps 1.1 and 1.2.
  2. Store the new records in the AWSMarketplaceMeteringRecords To do that, do the following:
    1. Navigate to Amazon DynamoDB console.
    2. Select the AWSMarketplaceMeteringRecords table created by running the CloudFormation stack that the SaaS Quick Start
    3. Select Explore table items and then Create Item. Choose JSON.
    4. Paste the JSON content you created in steps 1.1 and 1.2. Choose Create Item.

When the record is submitted to AWS Marketplace BatchMeterUsage API, it will be updated and it will look similar to this:

{

  "create_timestamp": {

    "N": "113123"

  },

  "customerIdentifier": {

    "S": "ifAPi5AcF3"

  },

  "dimension_usage": {

    "L": [

      {

        "M": {

          "dimension": {

            "S": "admin_users"

          },

          "value": {

            "N": "3"

          }

        }

      }

    ]

  },

  "metering_failed": {

    "BOOL": false

  },

  "metering_response": {

    "S": "{\"Results\":[{\"UsageRecord\":{\"Timestamp\":\"2020-06-24T04:04:53.776Z\",\"CustomerIdentifier\":\"ifAPi5AcF3\",\"Dimension\":\"admin_users\",\"Quantity\":3},\"MeteringRecordId\":\"35155d37-56cb-423f-8554-5c4f3e3ff56d\",\"Status\":\"Success\"}],\"UnprocessedRecords\":[]}"

  }

}

  1. (Optional alternative to step 3). Alternatively, you can use the AWS CLI to insert the record in the AWSMarketplaceMeteringRecords table. To do this, follow steps 1 and 2. Then, in the following command, use that JSON file:

aws dynamodb put-item –table-name AWSMarketplaceMeteringRecords –ite

When the record is submitted successfully to AWS Marketplace BatchMeterUsage API, then it will it will be updated and it will look similar to step 4.

Conclusion and next steps

In this post, I showed how to meter for usage when you used the SaaS Quick Start for your subscription or your contract with consumption SaaS products. After following these steps, you can report usage for your SaaS Subscription and Contract with Consumption.

About the author

Pawan KumarPawan Kumar is a Technical Account Manager who focuses on seller operations for AWS Marketplace and is passionate about serverless computing and solving new problems. Outside of work, he enjoys playing and watching cricket.