Boto3 has a function that allows you to create volume permissions, which is what AMI Sharing with AWS Marketplace requires you to do.
snapshot.modify_attribute will allow you to share your AMI with the marketplace account like so (you can also use a JSON representation if you prefer, it's in the docs):
response = snapshot.modify_attribute(
Attribute = 'createVolumePermission',
OperationType = 'add',
UserIds = [
'679593333241', # Marketplace user ID
There is also an official API function that will help you achieve the permissions requirement listed in AMI Sharing with AWS Marketplace if you decide to migrate from boto3 (or if a reader isn't using boto3). If your AMI is private, you need only make this API call:
This should add the permission that the marketplace needs to access your AMI. As for replacing
ID_HERE with the snapshot's ID, you can do that with boto3 by using your snapshot object's snapshot_id property
snapshot.snapshot_id before making the API call (that being said, there's little reason for you to use this API since you have to use boto3 anyways).
You should be able to use the relevant ServiceCatalog functions in boto3 such as
create_product to upload product metadata. There are also equivalent official API functions (this one is just CreateProduct, they're not listed in a way that allows me to link to them nicely). It's worth noting that the official API only accepts JSON whereas boto3 will generate the JSON itself. Which one is more useful to you depends on how your data is structured in your product metadata file(s). Since I don't know that I can't directly write the code to do it.