Search code examples
amazon-web-servicesaws-cliamazon-marketplace

Automate AWS Marketplace publishing through CLI


I have my product uploaded to AWS as an AMI through Hashicorp's Packer. Now I'ld like to automate the last step, publishing it to the marketplace. The product already exists, it's only about adding a revision.

After reading this article, the API_StartChangeSet doc, this add revisions user guide & fiddling with the marketplace console, I think I just have to

aws marketplace-catalog start-change-set --catalog AWSMarketplace --change-set-name "$VERSION" --change-set '[ {"ChangeType": "AddRevisions", "Entity": {"Identifier": "REDACTED@29","Type": "[email protected]"}, "Details": "{\"DataSetArn\": \"?????\", \"RevisionArns\": [\"?????\"] }" ]'

I'm having a hard time coming up with "Details" part. I've my AMI id. I guess that goes in the RevisionsArns ? What should I put in the DataSetArn, the "EntityArn" from the output of aws marketplace-catalog describe-entity --catalog AWSMarketplace --entity-id REDACTED ?


Solution

  • Turns out I didn't found the good documentation, my last link being about AWS Data Exchange, whose "Details" field's contents were confusing.

    Here the relevant documentation: Marketplace catalog AMI add version, and here's the snippet I was looking for

          "Details": "{
            \"Version\": {
              \"VersionTitle\": \"*My new title*\",
              \"ReleaseNotes\": \"*My new Release notes*\"
            },
            \"DeliveryOptions\": [
              {
                \"Details\": {
                  \"AmiDeliveryOptionDetails\": {
                    \"AmiSource\": {
                      \"AmiId\": \"ami-1234567890abcdef\",
                      \"AccessRoleArn\": \"arn:aws:iam::12345678901:role/AwsMarketplaceAmiIngestion\",
                      \"UserName\": \"ec2-user\",
                      \"OperatingSystemName\": \"AMAZONLINUX\",
                      \"OperatingSystemVersion\": \"Amazon Linux 2 AMI 2.0.20210126.0 x86_64 HVM gp2\"
                    },
                    \"UsageInstructions\": \"Easy to use AMI\",
                    \"RecommendedInstanceType\": \"m4.xlarge\",
                    \"SecurityGroups\": [
                      {
                        \"IpProtocol\": \"tcp\",
                        \"FromPort\": 443,
                        \"ToPort\": 443,
                        \"IpRanges\": [
                          \"0.0.0.0/0\"
                        ]
                      }
                    ]
                  }
                }
              }
            ]
          }"