一千萬個為什麽

搜索


有沒有人知道一種方法來自動化提交AMI到亞馬遜的市場?我想采用公共AMI並將其分享到AWS Marketplace,以便掃描列表並提交產品元數據表。

我們首選的環境是Python,但是我沒有在 boto3 庫中看到任何相關的鉤子,所以我打開替代方案。

轉載註明原文: 自動提交亞馬遜商城

一共有 1 個回答:

快照權限

Boto3有一個功能,允許您創建音量權限,這就是 AMI與AWS Marketplace共享需要您做。 snapshot.modify_attribute 可以讓你像這樣分享你的AMI和市場賬戶(如果你願意,你也可以使用JSON表示,它在文檔中):

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

還有一個官方API函數,它將幫助您實現 AMI與AWS Marketplace共享中列出的權限要求如果您決定從boto3遷移(或者如果讀者不使用boto3)。如果您的AMI是私有的,則只需進行此API調用即可:

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

這應該增加市場訪問AMI所需的權限。至於用快照ID替換 ID_HERE ,您可以使用快照對象的 snapshot_id 屬性 snapshot.snapshot_id 在進行API調用之前(也就是說,您沒有理由使用它因為你必須使用boto3)。

產品元數據

You should be able to use the relevant ServiceCatalog functions in boto3 such as create_product to upload 產品元數據. 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 產品元數據 file(s). Since I don't know that I can't directly write the code to do it.