7

Is anyone aware of a way to automate the submission of an AMI to Amazon's Marketplace? I want to take a public AMI and share it to the AWS Marketplace so it can be scanned for listing and then submit the product metadata sheet.

Our preferred environment is Python, but I didn't see any relevant hooks in the boto3 library so I'm open to alternatives.

  • I'm unsure of what you're after, do you want to share your baked ami on the marketplace or just register an ami for your own use ? – Tensibai Mar 21 '17 at 22:00
  • I want to share a baked AMI on the Marketplace. The manual process for doing this involves sharing them in a specific way so they can be scanned and then submitting metadata about the AMIs. – lawnmowerlatte Mar 22 '17 at 0:43
  • Not really an answer, but a starting point maybe: Building AMIs for AWS Marketplace – Tensibai Mar 22 '17 at 10:35
  • @Tensibai, the section for AMI Sharing with AWS Marketplace looks promising. I'll keep this question updated as I continue researching. – lawnmowerlatte Mar 22 '17 at 14:02
6

Snapshot Permissions

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:

https://ec2.amazonaws.com/?Action=ModifySnapshotAttribute
&SnapshotId=ID_HERE
&CreateVolumePermission.Add.1.UserId=679593333241
&AUTHPARAMS

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).

Product Metadata

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.

  • 1. Does sharing the AMI & Snapshot w/ the Marketplace ID automatically queue it for scanning? Based on my manual testing, you still need to provide the OS username and initiate the scan by hand. – lawnmowerlatte Mar 22 '17 at 18:39
  • 2. Is there a way to check on the status of the AMI scan? – lawnmowerlatte Mar 22 '17 at 18:40
  • 3. I'm not sure the ServiceCatalog functions are what I'm looking for. The product exists, I just need to add a new version. The manual process is to submit the Product Load Form, referenced in the Seller Guide. – lawnmowerlatte Mar 22 '17 at 18:40
  • 2
    1: I just checked and no it doesn't, actually. The marketplace lacks an API so for this one and you'll need to "roll your own" with a special user account to trigger different things in the management console through automated form submissions. 2: No API, so you'll need to do it yourself again. 3: There are update functions in the ServiceCatalog like update_product() you can use if it already exists. – Peter G Mar 22 '17 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.