The following code examples use the AWS SDK for Java and AWS Marketplace Metering Service to call the MeterUsage operation.
The following code example calls the MeterUsage operation without any UsageAllocations.
import com.amazonaws.services.marketplacemetering.AWSMarketplaceMetering;
private static final String PRODUCT_CODE = "...";
private final AWSMarketplaceMetering awsMarketplaceMetering;
public MeterUsage() {
awsMarketplaceMetering = AWSMarketplaceMeteringClientBuilder.standard().build();
} /**
* Submits metering record for a FCP Dimension. The API accepts 1 metering record per dimension
* @param dimension - FCP dimension name provided during the publishing of the product.
* @param quantity - FCP dimension consumption value for the hour.
* @param timestamp - Timestamp, in UTC, for which the usage is being reported.
* Timestamp cant be more than 1 hour in the past.
* Make sure the timestamp value is not before the start of the software usage.
Custom metering with AWS Marketplace Metering Service
*/
public void callMeterUsage(String dimension, int quantity, Date timestamp) { MeterUsageRequest meterUsageRequest = new MeterUsageRequest()
.withProductCode(PRODUCT_CODE)
The following code example calls the MeterUsage operation with UsageAllocations.
private static String callMeterUsageWithAllocationsByTag(AWSMarketplaceMetering
// 1st Usage Allocation bucket which has two Tags [{Key1, Key1Value1},{Key2, Key2Value1}]
List<Tag> tagsForUsageAllocation1 = Arrays.asList(new Tag().withKey(tagKey1).withValue("Key1Value1"),
new Tag().withKey(tagKey2).withValue("Key2Value1"));
UsageAllocation usageAllocation1 = new UsageAllocation() .withTags(tagsForUsageAllocation1)
.withAllocatedUsageQuantity(20);
// 2nd Usage Allocation bucket which has two Tags [{Key1, Key1Value2},{Key2, Key2Value1}]
List<Tag> tagsForUsageAllocation2 = Arrays.asList(new Tag().withKey(tagKey1).withValue("Key1Value2"),
new Tag().withKey(tagKey2).withValue("Key2Value1"));
UsageAllocation usageAllocation2 = new UsageAllocation() .withTags(tagsForUsageAllocation2)
.withAllocatedUsageQuantity(20);
// 3rd Usage Allocation bucket which has two Tags [{Key1, Key1Value2},{Key2, Key2Value2},{Key3, Key3Value1}]
List<Tag> tagsForUsageAllocation3 = Arrays.asList(new Tag().withKey(tagKey1).withValue("Key1Value2"),
new Tag().withKey(tagKey2).withValue("Key2Value2"), new Tag().withKey(tagKey3).withValue("Key3Value1"));
UsageAllocation usageAllocation3 = new UsageAllocation() .withTags(tagsForUsageAllocation3)
.withAllocatedUsageQuantity(15);
// 4th Usage Allocation bucket with no tags
UsageAllocation usageAllocation4 = new UsageAllocation() .withAllocatedUsageQuantity(15);
List<UsageAllocation> usageAllocationList = Arrays.asList(usageAllocation1, usageAllocation2,
usageAllocation3, usageAllocation4);
MeterUsageRequest meterUsageRequest = new MeterUsageRequest() .withProductCode("TestProductCode")
Contract pricing with AWS License Manager
MeterUsageResult meterUsageResult;
try {
meterUsageResult = marketplaceMetering.meterUsage(meterUsageRequest);
} catch (Exception e) { // Log Error throw e;
}
return meterUsageResult.getMeteringRecordId();
}
Contract pricing with AWS License Manager
For container-based products with contract pricing, use AWS License Manager to associate licenses with your product.
AWS License Manager is a license management tool that enables your application to track and update licenses (also known as entitlements) that have been purchased by a customer. This section provides information about how to integrate your product with AWS License Manager. After the integration is complete, you can publish your product listing on AWS Marketplace.
If you're integrating License Manager with an AWS Marketplace for Containers Anywhere product for Amazon EKS Anywhere, Amazon ECS Anywhere, Amazon Elastic Compute Cloud (Amazon EC2), or on-premises infrastructure, follow the instructions in Integrating an AWS Marketplace for Containers Anywhere product with License Manager (p. 158).
For more information about AWS License Manager, see the AWS License Manager User Guide and the AWS License Manager section of the AWS CLI Command Reference.
License models
AWS Marketplace integration with AWS License Manager supports two license models:
• Configurable license model (p. 153)
• Tiered license model (p. 156)
Configurable license model
The configurable license model (also known as the quantifiable license model) entitles a buyer to a specific quantity of resources after a buyer has procured a license.
You set a pricing dimension and a per unit price. Then, the buyer can choose the quantity of the resources that they want to purchase.
Example of pricing dimension and per unit price
You can set a pricing dimension (such as data backup) and per unit price (such as $30/unit).
The buyer can choose to purchase 5, 10, or 20 units.
Your product tracks and meters usage to measure the quantity of resources consumed.
With the configuration model, the entitlements are counted in one of two ways:
• Drawdown licenses (p. 154)
Contract pricing with AWS License Manager
• Floating licenses (p. 154)
Drawdown license
The license is drawn from the pool of allowed amount of licenses upon use. That entitlement is checked out permanently and can't be returned to the license pool.
Example of processing a limited amount of data
A user is entitled to process 500 GB of data. As they continue to process data, the quantity is drawn from the pool of 500 GB until all 500 GB licenses are consumed.
For drawdown licenses, you can use the CheckoutLicense API operation to check out license units (entitlements) that are consumed.
Example of backup to S3 for a number of units/year
You have a storage product that allows backup to Amazon Simple Storage Service (Amazon S3) for up to 1,024 units for data for one year. Your application can be launched by using multiple Amazon EC2 instances. Your application has a mechanism to track and aggregate data. Your software calls the CheckoutLicense API operation with the Product ID upon every backup or at fixed intervals to update the consumed quantities.
In this example, your software calls the CheckoutLicense API operation to check out 10 units of data.
When the total capacity reaches the backup limit that the customer has purchased, the API call fails.
Request
linux-machine ~]$ aws license-manager checkout-license\
--product-sku "2205b290-19e6-4c76-9eea-377d6bf7la47" \ --checkout-type "PERPETUAL" \
--key-fingerprint "aws:294406891311:AWS/Marketplace:issuer-fingerprint" \ --entitlements "Name=DataConsumption, Value=l0, Unit=Count" \
--client-token "AKIAIOSFODNN7EXAMPLE"
Response
{
"CheckoutType": "PERPETUAL", "EntitlementsAllowed": [ {
"Name": "DataConsumption", "Count": 10,
"Units": "Count", "Value": "Enabled"
}
}, "Expiration": "2021-04-22Tl9:02: 36", "IssuedAt": "2021-04-22Tl8:02:36",
"LicenseArn": "arn:aws:license-manager::294406891311:license:l-16bf01b...", "LicenseConsumptionToken": "AKIAIOSFODNN7EXAMPLE"
}
Floating licenses
The license is returned to the pool of the allowed amount of licenses after use.
For floating licenses, the application checks out entitlements from the entitlements pool using the CheckoutLicense API operation when the resource is being used. The response of the
Contract pricing with AWS License Manager
CheckoutLicense API operation includes a license consumption token which is a unique identifier for the checkout. The license consumption token can be used to perform additional actions on the entitlements checked out, such as checking them back into the license or extending the checkout.
To check the entitlement back into the pool, use the CheckInLicense API operation when the resource is no longer in use.
aws license-manager check-in-license --license-consumption-token "f1603b3c1f574b7284db84..."
In case of failure to check in the entitlement (in case the application crashed), the entitlement checks back into the pool automatically after 60 minutes. If the resource is in use longer than 60 minutes, it is a best practice to keep the entitlement checked out of the pool by using the ExtendLicenseConsumption API operation as long as the resource is being used.
aws license-manager extend-license-consumption --license-consumption-token "f1603b3c1f574b7284..."
Example of number of users from a fixed upper limit
A user is entitled to 500 simultaneous users on the application. As users log in and log out, the users are drawn and returned to the pool of 500 users. However, the application can't draw more than 500 users from the pool because 500 simultaneous users is the fixed upper limit.
For floating entitlements, you can use the CheckInLicense API operation to return the license units to the entitlement pool.
Example of number of concurrent users for one year
Your product is priced based on number of concurrent users. The customer purchases a license for 10 users for one year. The customer launches the software by providing AWS Identity and Access Management (IAM) permissions. When a user logs in, your application calls the CheckoutLicense API operation to reduce the quantity by 1. When the user logs out, the application returns that license to the pool by calling the CheckInLicense API operation. If you don't call CheckInLicense, the license unit will be automatically checked in after 1 hour.
Note
In the following Request, the key-fingerprint isn't a placeholder value but the actual value of the fingerprint with which all licenses will be published.
Request
aws license-manager checkout-license\
--product-sku "2205b290-19e6-4c76-9eea-377d6bf7la47" \ --checkout-type "PROVISIONAL" \
--key-fingerprint "aws:294406891311:AWS/Marketplace:issuer-fingerprint" \ --entitlements "Name=ReadOnlyUSers, Value=l0, Unit=Count" \
--client-token "AKIAIOSFODNN7EXAMPLE"
Response
{ "CheckoutType": "PROVISIONAL", "EntitlementsAllowed": [ {
"Name": "ReadOnlyUsers",
Contract pricing with AWS License Manager
"Count": 10, "Units": "Count", "Value": "Enabled"
}
}, "Expiration": "2021-04-22Tl9:02: 36", "IssuedAt": "2021-04-22Tl8:02:36",
"LicenseArn": "arn:aws:license-manager::294406891311:license:l-16bf01b...", "LicenseConsumptionToken": "AKIAIOSFODNN7EXAMPLE"
}
Tiered license model
The tiered license model entitles a buyer to a specific level, or tier, of application features after a buyer has procured a license.
You create tiers for your product, such as Basic, Intermediate, and Premium. The buyer then selects one of the predefined tiers.
The application doesn't need to track or meter usage of the application.
With the tiered license model, the entitlements aren't counted but instead signify a tier of service that was procured by the customer.
If you want to offer bundled features together, tiers are preferable.
Example of Basic, Intermediate, and Premium tiers
A customer can sign a contract for one of three possible tiers of the software: Basic, Intermediate, or Premium. Each of these tiers has its own pricing. Your software can identify the tier that the customer has signed up for by invoking the CheckoutLicense API operation and specifying all possible tiers in the request.
The response of the request contains the entitlement corresponding to the tier that the customer has procured. Based on this information, the software can provision the appropriate customer experience.
Request
linux-machine ~]$ aws license-manager checkout-license\
--product-sku "2205b290-19e6-4c76-9eea-377d6bf7la47" \ --checkout-type "PROVISIONAL" \
--key-fingerprint "aws:294406891311:AWS/Marketplace:issuer-fingerprint" \
--entitlements "Name=BasicTier, Unit=None" "Name=IntermediateTier, Unit=None" \ "Name=PremiumTier, Unit=None"
Response
{ "CheckoutType": "PROVISIONAL", "EntitlementsAllowed": [ {
"Name": "IntermediateTier", "Units": "None"
}
}, "Expiration": "2021-04-22Tl9:02:36", "IssuedAt": "2021-04-22Tl8:02:36",
"LicenseArn": "arn:aws:license-manager::294406891311:license:l-16bf01b...", "LicenseConsumptionToken": "AKIAIOSFODNN7EXAMPLE"
Contract pricing with AWS License Manager
}