AWS Marketplace Cleanup

Share on:

Quarterly, at the very least, I always like to go through my AWS accounts (in this case, it was a separate AWS account not in my AWS Organization) and verify that I’m not being billed for something I’m not utilizing. In this recent case, this AWS account has been around the “block” for quite some time, therefore I assumed I had a treasure-trove of leftover AWS Marketplace subscriptions that I no longer had a use for.

AWS Marketplace is a curated digital catalog that customers can use to find, buy, deploy, and manage third-party software, data, and services to build solutions and run their businesses. AWS Marketplace includes thousands of software listings from popular categories such as security, business applications, machine learning, and data products across specific industries, such as healthcare, financial services, and telecommunications. Customers can quickly launch preconfigured software, and choose software solutions in Amazon Machine Images (AMIs), software as a service (SaaS), and other formats. Professional services are also available to help customers configure, deploy, and manage third-party software. https://docs.aws.amazon.com/marketplace/latest/userguide/what-is-marketplace.html

Well - In this case, there was about 8 different AWS Marketplace subscriptions that were still active (albeit $0 cost). Eeek! Even at $0, cost is always top of mind when building for me. I understand there is a negotiated term when accepting an AWS Marketplace subscription, however I’m always mindful of those terms changing. This leads me to my set of questions (and obstacle)..

  1. Programmatically - How do I list my current AWS Marketplace Subscriptions?

    The list-entities call of the AWS CLI will list out our current AWS Marketplace Subscriptions There is many different AWS Marketplace entity-types:

    --entity-type (string)

    The type of entities to retrieve. Valid values are: AmiProduct , ContainerProduct , DataProduct , SaaSProduct , ProcurementPolicy , Experience , Audience , BrandingSettings , Offer , Seller , ResaleAuthorization .

    Can we programmatically list the AWS Marketplace listing? Sure! Let’s lean on Python 3.x to list our AWS Marketplace subscriptions:

     import subprocess
     import json
    
     entity_types = ["AmiProduct", "ContainerProduct", "DataProduct", "SaaSProduct",
                     "ProcurementPolicy", "Experience", "Audience", "BrandingSettings",
                     "Offer", "Seller", "ResaleAuthorization"]
    
     for entity_type in entity_types:
         command = [
             "aws",
             "marketplace-catalog",
             "list-entities",
             "--catalog", "AWSMarketplace",
             "--entity-type", entity_type,
             "--output", "json"
         ]
    
         result = subprocess.run(command, capture_output=True, text=True)
    
         if result.returncode == 0:
             output_json = json.loads(result.stdout)
             # Process the output as needed, for example, print the results
             print(f"Entities for {entity_type}: {output_json}")
         else:
             print(f"Error executing command for {entity_type}: {result.stderr}")
    

    This is great! It lists our current AWS Marketplace subscriptions:

     tdieter@d-desktop:~$ python test_removal.py
     Entities for AmiProduct: {'EntitySummaryList': []}
     Entities for ContainerProduct: {'EntitySummaryList': []}
     Entities for DataProduct: {'EntitySummaryList': []}
     Entities for SaaSProduct: {'EntitySummaryList': []}
     Entities for ProcurementPolicy: {'EntitySummaryList': []}
     Entities for Experience: {'EntitySummaryList': []}
     Entities for Audience: {'EntitySummaryList': []}
     Entities for BrandingSettings: {'EntitySummaryList': []}
     Entities for Offer: {'EntitySummaryList': []}
     Entities for Seller: {'EntitySummaryList': [{'Name': 'Troy', 'EntityType': 'Seller', 'EntityId': 'REDACTED', 'EntityArn': 'arn:aws:aws-marketplace:us-east-X:REDACTED:AWSMarketplace/Seller/REDACTED', 'LastModifiedDate': '2023-09-13T00:19:05Z'}]}
     Entities for ResaleAuthorization: {'EntitySummaryList': []}
    
  2. Now that we have an accounting of our current AWS Marketplace subscriptions in the account.. how do we remove them all? For example, we want to ensure there is no extra billing of unneeded SaaS type products that we used many moons back (for example, a Bitnami WordPress installation).

    In this case, I haven’t found an answer quite yet for this. I’d LOVE to hear from you - the community, on the best course of action to handle this programmatically!

ClickOps to the rescue.. until our next blog post where we find out the best course of action to programmatically delete these! :)

ClickOps

Until next time, #AWS Community!