The AWS Marketplace API Reference was restructured. For more information about the supported API operations, see the AWS Marketplace API Reference.
Amend an AMI ConfigurableUpfrontPricingTerm for usage pricing model using an AWS SDK
The following code examples show how to amend an AMI agreement with ConfigurableUpfrontPricingTerm by updating dimension quantity for usage pricing model.
- Java
-
- SDK for Java 2.x
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library
repository. package com.example.awsmarketplace.agreementapi.buyer; import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider; import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.services.marketplaceagreement.MarketplaceAgreementClient; import software.amazon.awssdk.services.marketplaceagreement.model.AcceptAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.AcceptAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.ConfigurableUpfrontPricingTermConfiguration; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestRequest; import software.amazon.awssdk.services.marketplaceagreement.model.CreateAgreementRequestResponse; import software.amazon.awssdk.services.marketplaceagreement.model.Dimension; import software.amazon.awssdk.services.marketplaceagreement.model.GetAgreementEntitlementsResponse; import software.amazon.awssdk.services.marketplaceagreement.model.Intent; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTerm; import software.amazon.awssdk.services.marketplaceagreement.model.RequestedTermConfiguration; import utils.AgreementApiUtils; /** * Demonstrates how to create an AMI agreement with ConfigurableUpfrontPricingTerm and then amend the dimension quantity * using the AWS Marketplace Agreement Service APIs. * * <p>Scenario: An AMI product with USAGE pricing requires two agreements: * <ol> * <li>An agreement with <b>usageBasedPricingTerm (UBPT)</b> — accepted first to establish the base agreement.</li> * <li>An agreement with <b>configurableUpfrontPricingTerm (CUPT)</b> — accepted after the UBPT agreement entitlements are active.</li> * </ol> * Once both agreement entitlements are available, this sample shows how to <b>amend</b> the agreement * with configurableUpfrontPricingTerm (CUPT) to increase the dimension quantity. * * <p>Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offer: * <ul> * <li>{@code AGREEMENT_PROPOSAL_IDENTIFIER} — the agreementProposalId from the offer.</li> * <li>Term IDs (starting with {@code term-}) — found in the offer's term list.</li> * <li>{@code SELECTOR_VALUE} — duration for the agreement * (e.g., {@code P365D} for one year).</li> * <li>{@code DIMENSION_1_KEY} — the dimension key defined in the offer (e.g., instance type).</li> * <li>{@code DIMENSION_1_VALUE} — initial quantity; {@code NEW_DIMENSION_1_VALUE} — amended quantity.</li> * </ul> */ public class AmendAmiConfigurableUpfrontPricingTermForUsagePricingModel { // The agreementProposalId from the offer. private static final String AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in your offer. private static final String CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P365D" for 365 days). private static final String SELECTOR_VALUE = "<your-selector-value>"; // The dimension key defined in your offer (e.g., an EC2 instance type like "c6gn.medium"). private static final String DIMENSION_1_KEY = "<your-dimension-key>"; // Initial quantity for the dimension. private static final int DIMENSION_1_VALUE = 1; // Term ID for the UsageBasedPricingTerm in your offer. private static final String USAGE_TERM_ID = "<your-usage-term-id>"; // Term ID for the LegalTerm in your offer. private static final String LEGAL_TERM_ID = "<your-legal-term-id>"; // Term ID for the ValidityTerm in your offer. private static final String VALIDITY_TERM_ID = "<your-validity-term-id>"; // New quantity to use when amending the dimension of CUPT. private static final int NEW_DIMENSION_1_VALUE = 5; public static void main(String[] args) { amendAmiCUPTAgreement(); } /** * Full end-to-end flow: * 1. Create and accept an agreement request with usageBasedPricingTerm. * 2. Wait for entitlements to become active, then create and accept an agreement request with configurableUpfrontPricingTerm (CUPT). * 3. Wait for CUPT entitlements to become active, then amend the dimension quantity. */ private static void amendAmiCUPTAgreement() { MarketplaceAgreementClient marketplaceAgreementClient = MarketplaceAgreementClient.builder() .httpClient(ApacheHttpClient.builder().build()) .credentialsProvider(ProfileCredentialsProvider.create()) .build(); RequestedTerm usageTerm = RequestedTerm.builder() .id(USAGE_TERM_ID) .build(); RequestedTerm legalTerm = RequestedTerm.builder() .id(LEGAL_TERM_ID) .build(); RequestedTerm validityTerm = RequestedTerm.builder() .id(VALIDITY_TERM_ID) .build(); // --- Agreement with UBPT --- CreateAgreementRequestRequest createAgreementRequestRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(usageTerm, legalTerm, validityTerm) .agreementProposalIdentifier(AGREEMENT_PROPOSAL_IDENTIFIER) .build(); CreateAgreementRequestResponse createAgreementRequestResponse = marketplaceAgreementClient.createAgreementRequest(createAgreementRequestRequest); System.out.println("Agreement request with UBPT created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId()); AcceptAgreementRequestRequest acceptAgreementRequestRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(createAgreementRequestResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse acceptAgreementRequestResponse = marketplaceAgreementClient.acceptAgreementRequest(acceptAgreementRequestRequest); System.out.println("Agreement request with UBPT accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId()); // Wait for entitlements to become active before creating the agreement with CUPT. System.out.println("Waiting for UBPT agreement entitlements to become active..."); GetAgreementEntitlementsResponse entitlementsResponse = AgreementApiUtils.pollUntilEntitlementsAvailable( marketplaceAgreementClient, acceptAgreementRequestResponse.agreementId()); System.out.println("UBPT agreement entitlements are now active."); AgreementApiUtils.formatOutput(entitlementsResponse); // --- Agreement with configurableUpfrontPricingTerm (CUPT) --- RequestedTerm configurableUpfrontPricingTerm = RequestedTerm.builder() .id(CONFIGURABLE_UPFRONT_PRICING_TERM_ID) .configuration(RequestedTermConfiguration.fromConfigurableUpfrontPricingTermConfiguration( ConfigurableUpfrontPricingTermConfiguration.builder() .selectorValue(SELECTOR_VALUE) .dimensions(Dimension.builder() .dimensionKey(DIMENSION_1_KEY) .dimensionValue(DIMENSION_1_VALUE) .build()) .build())) .build(); CreateAgreementRequestRequest carRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.NEW) .requestedTerms(configurableUpfrontPricingTerm, legalTerm, validityTerm) .agreementProposalIdentifier(AGREEMENT_PROPOSAL_IDENTIFIER) .build(); CreateAgreementRequestResponse carResponse = marketplaceAgreementClient.createAgreementRequest(carRequest); System.out.println("Agreement request with CUPT created. AgreementRequestId: " + carResponse.agreementRequestId()); AcceptAgreementRequestRequest aarRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(carResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse aarResponse = marketplaceAgreementClient.acceptAgreementRequest(aarRequest); final String cuptAgreementId = aarResponse.agreementId(); System.out.println("Agreement request with CUPT accepted. AgreementId: " + cuptAgreementId); // Wait for entitlements to become active before amending. System.out.println("Waiting for CUPT agreement entitlements to become active..."); GetAgreementEntitlementsResponse cuptEntitlementsResponse = AgreementApiUtils.pollUntilEntitlementsAvailable( marketplaceAgreementClient, cuptAgreementId); System.out.println("CUPT agreement entitlements are now active."); AgreementApiUtils.formatOutput(cuptEntitlementsResponse); // --- Amend Agreement with CUPT --- // Increase the dimension quantity using Intent.AMEND and sourceAgreementIdentifier. RequestedTerm newConfig = RequestedTerm.builder() .id(CONFIGURABLE_UPFRONT_PRICING_TERM_ID) .configuration(RequestedTermConfiguration.fromConfigurableUpfrontPricingTermConfiguration( ConfigurableUpfrontPricingTermConfiguration.builder() .selectorValue(SELECTOR_VALUE) .dimensions(Dimension.builder() .dimensionKey(DIMENSION_1_KEY) .dimensionValue(NEW_DIMENSION_1_VALUE) // Increase quantity for this dimension key .build()) .build())) .build(); CreateAgreementRequestRequest carAmendRequest = CreateAgreementRequestRequest.builder() .clientToken(AgreementApiUtils.generateClientToken()) .intent(Intent.AMEND) .requestedTerms(newConfig, legalTerm, validityTerm) .sourceAgreementIdentifier(cuptAgreementId) .build(); CreateAgreementRequestResponse carAmendResponse = marketplaceAgreementClient.createAgreementRequest(carAmendRequest); System.out.println("Amendment of CUPT agreement request created. AgreementRequestId: " + carAmendResponse.agreementRequestId()); AcceptAgreementRequestRequest aarAmendRequest = AcceptAgreementRequestRequest.builder() .agreementRequestId(carAmendResponse.agreementRequestId()) .build(); AcceptAgreementRequestResponse aarAmendResponse = marketplaceAgreementClient.acceptAgreementRequest(aarAmendRequest); System.out.println("Amendment accepted. New AgreementId: " + aarAmendResponse.agreementId()); } }-
For API details, see CreateAgreementRequest in AWS SDK for Java 2.x API Reference.
-
- JavaScript
-
- SDK for JavaScript (v3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library
repository. const { MarketplaceAgreementClient, CreateAgreementRequestCommand, AcceptAgreementRequestCommand, } = require("@aws-sdk/client-marketplace-agreement"); const { generateClientToken, formatOutput, pollUntilEntitlementsAvailable } = require("./utils/AgreementApiUtils"); /** * Demonstrates how to create an AMI agreement with ConfigurableUpfrontPricingTerm and then amend the dimension quantity * using the AWS Marketplace Agreement Service APIs. * * Scenario: An AMI product with USAGE pricing requires two agreements: * 1. An agreement with usageBasedPricingTerm (UBPT) — accepted first to establish the base agreement. * 2. An agreement with configurableUpfrontPricingTerm (CUPT) — accepted after the UBPT agreement entitlements are active. * * Once both agreement entitlements are available, this sample shows how to amend the agreement * with configurableUpfrontPricingTerm (CUPT) to increase the dimension quantity. * * Before running this sample, replace the placeholder constants below with values from * your AWS Marketplace offer: * - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the offer. * - Term IDs (starting with "term-") — found in the offer's term list. * - SELECTOR_VALUE — duration for the agreement (e.g., "P365D" for one year). * - DIMENSION_1_KEY — the dimension key defined in the offer (e.g., instance type). * - DIMENSION_1_VALUE — initial quantity; NEW_DIMENSION_1_VALUE — amended quantity. */ // The agreementProposalId from the offer. const AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>"; // Term ID for the ConfigurableUpfrontPricingTerm in your offer. const CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>"; // Duration for the agreement (e.g., "P365D" for 365 days). const SELECTOR_VALUE = "<your-selector-value>"; // The dimension key defined in your offer (e.g., an EC2 instance type like "c6gn.medium"). const DIMENSION_1_KEY = "<your-dimension-key>"; // Initial quantity for the dimension. const DIMENSION_1_VALUE = 1; // Term ID for the UsageBasedPricingTerm in your offer. const USAGE_TERM_ID = "<your-usage-term-id>"; // Term ID for the LegalTerm in your offer. const LEGAL_TERM_ID = "<your-legal-term-id>"; // Term ID for the ValidityTerm in your offer. const VALIDITY_TERM_ID = "<your-validity-term-id>"; // New quantity to use when amending the dimension of CUPT. const NEW_DIMENSION_1_VALUE = 5; /** * Full end-to-end flow: * 1. Create and accept an agreement request with usageBasedPricingTerm. * 2. Wait for entitlements to become active, then create and accept an agreement request with configurableUpfrontPricingTerm (CUPT). * 3. Wait for CUPT entitlements to become active, then amend the dimension quantity. */ async function amendAmiCUPTAgreement() { const client = new MarketplaceAgreementClient(); const usageTerm = { id: USAGE_TERM_ID }; const legalTerm = { id: LEGAL_TERM_ID }; const validityTerm = { id: VALIDITY_TERM_ID }; // --- Agreement with UBPT --- const createAgreementRequestResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [usageTerm, legalTerm, validityTerm], agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request with UBPT created. AgreementRequestId: " + createAgreementRequestResponse.agreementRequestId); const acceptAgreementRequestResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: createAgreementRequestResponse.agreementRequestId, }) ); console.log("Agreement request with UBPT accepted. AgreementId: " + acceptAgreementRequestResponse.agreementId); // Wait for entitlements to become active before creating the agreement with CUPT. console.log("Waiting for UBPT agreement entitlements to become active..."); const entitlementsResponse = await pollUntilEntitlementsAvailable(client, acceptAgreementRequestResponse.agreementId); console.log("UBPT agreement entitlements are now active."); formatOutput(entitlementsResponse); // --- Agreement with configurableUpfrontPricingTerm (CUPT) --- const configurableUpfrontPricingTerm = { id: CONFIGURABLE_UPFRONT_PRICING_TERM_ID, configuration: { configurableUpfrontPricingTermConfiguration: { selectorValue: SELECTOR_VALUE, dimensions: [ { dimensionKey: DIMENSION_1_KEY, dimensionValue: DIMENSION_1_VALUE }, ], }, }, }; const carResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "NEW", requestedTerms: [configurableUpfrontPricingTerm, legalTerm, validityTerm], agreementProposalIdentifier: AGREEMENT_PROPOSAL_IDENTIFIER, }) ); console.log("Agreement request with CUPT created. AgreementRequestId: " + carResponse.agreementRequestId); const aarResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: carResponse.agreementRequestId, }) ); const cuptAgreementId = aarResponse.agreementId; console.log("Agreement request with CUPT accepted. AgreementId: " + cuptAgreementId); // Wait for entitlements to become active before amending. console.log("Waiting for CUPT agreement entitlements to become active..."); const cuptEntitlementsResponse = await pollUntilEntitlementsAvailable(client, cuptAgreementId); console.log("CUPT agreement entitlements are now active."); formatOutput(cuptEntitlementsResponse); // --- Amend Agreement with CUPT --- // Increase the dimension quantity using Intent.AMEND and sourceAgreementIdentifier. const newConfig = { id: CONFIGURABLE_UPFRONT_PRICING_TERM_ID, configuration: { configurableUpfrontPricingTermConfiguration: { selectorValue: SELECTOR_VALUE, dimensions: [ { dimensionKey: DIMENSION_1_KEY, dimensionValue: NEW_DIMENSION_1_VALUE }, // Increase quantity for this dimension key ], }, }, }; const carAmendResponse = await client.send( new CreateAgreementRequestCommand({ clientToken: generateClientToken(), intent: "AMEND", requestedTerms: [newConfig, legalTerm, validityTerm], sourceAgreementIdentifier: cuptAgreementId, }) ); console.log("Amendment of CUPT agreement request created. AgreementRequestId: " + carAmendResponse.agreementRequestId); const aarAmendResponse = await client.send( new AcceptAgreementRequestCommand({ agreementRequestId: carAmendResponse.agreementRequestId, }) ); console.log("Amendment accepted. New AgreementId: " + aarAmendResponse.agreementId); } amendAmiCUPTAgreement();-
For API details, see CreateAgreementRequest in AWS SDK for JavaScript API Reference.
-
- Python
-
- SDK for Python (Boto3)
-
Note
There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Marketplace API Reference Code Library
repository. """ Demonstrates how to create an AMI agreement with ConfigurableUpfrontPricingTerm and then amend the dimension quantity using the AWS Marketplace Agreement Service APIs. Scenario: An AMI product with USAGE pricing requires two agreements: 1. An agreement with usageBasedPricingTerm (UBPT) — accepted first to establish the base agreement. 2. An agreement with configurableUpfrontPricingTerm (CUPT) — accepted after the UBPT agreement entitlements are active. Once both agreement entitlements are available, this sample shows how to amend the agreement with configurableUpfrontPricingTerm (CUPT) to increase the dimension quantity. Before running this sample, replace the placeholder constants below with values from your AWS Marketplace offer: - AGREEMENT_PROPOSAL_IDENTIFIER — the agreementProposalId from the offer. - Term IDs (starting with term-) — found in the offer's term list. - SELECTOR_VALUE — duration for the agreement (e.g., P365D for one year). - DIMENSION_1_KEY — the dimension key defined in the offer (e.g., instance type). - DIMENSION_1_VALUE — initial quantity; NEW_DIMENSION_1_VALUE — amended quantity. """ import boto3 from utils.agreement_api_utils import ( format_output, generate_client_token, poll_until_entitlements_available, ) class AmendAmiConfigurableUpfrontPricingTermForUsagePricingModel: # The agreementProposalId from the offer. AGREEMENT_PROPOSAL_IDENTIFIER = "<your-agreement-proposal-identifier>" # Term ID for the ConfigurableUpfrontPricingTerm in your offer. CONFIGURABLE_UPFRONT_PRICING_TERM_ID = "<your-configurable-upfront-pricing-term-id>" # Duration for the agreement (e.g., "P365D" for 365 days). SELECTOR_VALUE = "<your-selector-value>" # The dimension key defined in your offer (e.g., an EC2 instance type like "c6gn.medium"). DIMENSION_1_KEY = "<your-dimension-key>" # Initial quantity for the dimension. DIMENSION_1_VALUE = 1 # Term ID for the UsageBasedPricingTerm in your offer. USAGE_TERM_ID = "<your-usage-term-id>" # Term ID for the LegalTerm in your offer. LEGAL_TERM_ID = "<your-legal-term-id>" # Term ID for the ValidityTerm in your offer. VALIDITY_TERM_ID = "<your-validity-term-id>" # New quantity to use when amending the dimension of CUPT. NEW_DIMENSION_1_VALUE = 5 @staticmethod def amend_ami_cupt_agreement(): """ Full end-to-end flow: 1. Create and accept an agreement request with usageBasedPricingTerm. 2. Wait for entitlements to become active, then create and accept an agreement request with configurableUpfrontPricingTerm (CUPT). 3. Wait for CUPT entitlements to become active, then amend the dimension quantity. """ client = boto3.client("marketplace-agreement") cls = AmendAmiConfigurableUpfrontPricingTermForUsagePricingModel usage_term = {"id": cls.USAGE_TERM_ID} legal_term = {"id": cls.LEGAL_TERM_ID} validity_term = {"id": cls.VALIDITY_TERM_ID} # --- Agreement with UBPT --- create_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[usage_term, legal_term, validity_term], agreementProposalIdentifier=cls.AGREEMENT_PROPOSAL_IDENTIFIER, ) agreement_request_id = create_response["agreementRequestId"] print("Agreement request with UBPT created. AgreementRequestId: " + agreement_request_id) accept_response = client.accept_agreement_request( agreementRequestId=agreement_request_id ) agreement_id = accept_response["agreementId"] print("Agreement request with UBPT accepted. AgreementId: " + agreement_id) # Wait for entitlements to become active before creating the agreement with CUPT. print("Waiting for UBPT agreement entitlements to become active...") entitlements_response = poll_until_entitlements_available(client, agreement_id) print("UBPT agreement entitlements are now active.") format_output(entitlements_response) # --- Agreement with configurableUpfrontPricingTerm (CUPT) --- configurable_upfront_pricing_term = { "id": cls.CONFIGURABLE_UPFRONT_PRICING_TERM_ID, "configuration": { "configurableUpfrontPricingTermConfiguration": { "selectorValue": cls.SELECTOR_VALUE, "dimensions": [ { "dimensionKey": cls.DIMENSION_1_KEY, "dimensionValue": cls.DIMENSION_1_VALUE, }, ], } }, } car_response = client.create_agreement_request( clientToken=generate_client_token(), intent="NEW", requestedTerms=[configurable_upfront_pricing_term, legal_term, validity_term], agreementProposalIdentifier=cls.AGREEMENT_PROPOSAL_IDENTIFIER, ) print("Agreement request with CUPT created. AgreementRequestId: " + car_response["agreementRequestId"]) aar_response = client.accept_agreement_request( agreementRequestId=car_response["agreementRequestId"] ) cupt_agreement_id = aar_response["agreementId"] print("Agreement request with CUPT accepted. AgreementId: " + cupt_agreement_id) # Wait for entitlements to become active before amending. print("Waiting for CUPT agreement entitlements to become active...") cupt_entitlements_response = poll_until_entitlements_available(client, cupt_agreement_id) print("CUPT agreement entitlements are now active.") format_output(cupt_entitlements_response) # --- Amend Agreement with CUPT --- # Increase the dimension quantity using Intent.AMEND and sourceAgreementIdentifier. new_config = { "id": cls.CONFIGURABLE_UPFRONT_PRICING_TERM_ID, "configuration": { "configurableUpfrontPricingTermConfiguration": { "selectorValue": cls.SELECTOR_VALUE, "dimensions": [ { "dimensionKey": cls.DIMENSION_1_KEY, "dimensionValue": cls.NEW_DIMENSION_1_VALUE, # Increase quantity for this dimension key }, ], } }, } car_amend_response = client.create_agreement_request( clientToken=generate_client_token(), intent="AMEND", requestedTerms=[new_config, legal_term, validity_term], sourceAgreementIdentifier=cupt_agreement_id, ) print( "Amendment of CUPT agreement request created. AgreementRequestId: " + car_amend_response["agreementRequestId"] ) aar_amend_response = client.accept_agreement_request( agreementRequestId=car_amend_response["agreementRequestId"] ) print("Amendment accepted. New AgreementId: " + aar_amend_response["agreementId"]) if __name__ == "__main__": AmendAmiConfigurableUpfrontPricingTermForUsagePricingModel.amend_ami_cupt_agreement()-
For API details, see CreateAgreementRequest in AWS SDK for Python (Boto3) API Reference.
-
For a complete list of AWS SDK developer guides and code examples, see Using this service with an AWS SDK. This topic also includes information about getting started and details about previous SDK versions.