<h1>Snapshot Permissions</h1>

<p>Boto3 has a function that allows you to create volume permissions, which is what <a href="https://aws.amazon.com/marketplace/help/seller-building-AMIs?ref=help_ln_sibling#topic4" rel="noreferrer">AMI Sharing with AWS Marketplace</a> requires you to do. <code>snapshot.modify_attribute</code> 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):</p>

<pre><code>response = snapshot.modify_attribute(
    Attribute = 'createVolumePermission',
    OperationType = 'add',
    UserIds = [
        '679593333241', # Marketplace user ID
    ]
)
</code></pre>

<p>There is also an <a href="http://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ModifySnapshotAttribute.html" rel="noreferrer">official API function</a> that will help you achieve the permissions requirement listed in <a href="https://aws.amazon.com/marketplace/help/seller-building-AMIs?ref=help_ln_sibling#topic4" rel="noreferrer">AMI Sharing with AWS Marketplace</a> 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:</p>

<pre><code>https://ec2.amazonaws.com/?Action=ModifySnapshotAttribute
&amp;SnapshotId=ID_HERE
&amp;CreateVolumePermission.Add.1.UserId=679593333241
&amp;AUTHPARAMS
</code></pre>

<p>This should add the permission that the marketplace needs to access your AMI. As for replacing <code>ID_HERE</code> with the snapshot's ID, you can do that with boto3 by using your snapshot object's <a href="http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Snapshot.snapshot_id" rel="noreferrer">snapshot_id</a> property <code>snapshot.snapshot_id</code> 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).</p>

<h1>Product Metadata</h1>

<p>You should be able to use the <a href="http://boto3.readthedocs.io/en/latest/reference/services/servicecatalog.html" rel="noreferrer">relevant ServiceCatalog functions</a> in boto3 such as <code>create_product</code> to upload product metadata. There are also <a href="http://docs.aws.amazon.com/servicecatalog/latest/dg/API_CreateProduct.html" rel="noreferrer">equivalent official API functions</a> (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.</p>

CC BY-SA 3.0
2017-03-22T18:39:07.130Z
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
CC BY-SA 3.0
2017-03-22T18:40:19.387Z
2. Is there a way to check on the status of the AMI scan?
lawnmowerlatte
CC BY-SA 3.0
2017-03-22T18:40:25.297Z
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](http://awsmp-loadforms.s3.amazonaws.com/AWS_Marketplace_-_Seller_Guide.pdf).
lawnmowerlatte
CC BY-SA 3.0
2017-03-22T20:25:16.763Z
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
CC BY-SA 3.0
2017-03-22T17:43:00.713Z
2017-03-22T17:43:00.713Z
Peter G
<p>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.</p>

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

CC BY-SA 3.0
2017-03-21T22:00:32.000Z
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
CC BY-SA 3.0
2017-03-22T00:43:11.547Z
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
CC BY-SA 3.0
2017-03-22T10:35:55.980Z
Not really an answer, but a starting point maybe: [Building AMIs for AWS Marketplace](https://aws.amazon.com/marketplace/help/seller-building-AMIs?ref=help_ln_sibling)
Tensibai
CC BY-SA 3.0
2017-03-22T14:02:53.410Z
@Tensibai, the section for [AMI Sharing with AWS Marketplace](https://aws.amazon.com/marketplace/help/seller-building-AMIs?ref=help_ln_sibling#topic4) looks promising. I'll keep this question updated as I continue researching.
lawnmowerlatte
<amazon-web-services><continuous-deployment><automation><amazon-ec2>
How to automate submission to Amazon Marketplace?
lawnmowerlatte
# How to automate submission to Amazon Marketplace?

(Asked by: username_0 on 2017-03-21)

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.

**Tags:** amazon-web-services, continuous-deployment, automation, amazon-ec2

> **Comments:**
> **username_1**: 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 ?  
> **username_0**: 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.  
> **username_1**: Not really an answer, but a starting point maybe: [Building AMIs for AWS Marketplace](https://aws.amazon.com/marketplace/help/seller-building-AMIs?ref=help_ln_sibling)  
> **username_0**: @username_1, the section for [AMI Sharing with AWS Marketplace](https://aws.amazon.com/marketplace/help/seller-building-AMIs?ref=help_ln_sibling#topic4) looks promising. I'll keep this question updated as I continue researching.  

---

## 1 answers

### Answer by username_2 on 2017-03-22. Score: 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.

> **Comments:**
> **username_0**: 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.  
> **username_0**: 2. Is there a way to check on the status of the AMI scan?  
> **username_0**: 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](http://awsmp-loadforms.s3.amazonaws.com/AWS_Marketplace_-_Seller_Guide.pdf).  
> **username_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.  

---

