Skip to content

feat(packaging): let recipe versions build on imported Marketplace images - #204

Open
ganhammar wants to merge 2 commits into
awslabs:mainfrom
ganhammar:feat/recipe-marketplace-base
Open

ganhammar wants to merge 2 commits into
awslabs:mainfrom
ganhammar:feat/recipe-marketplace-base

Conversation

@ganhammar

Copy link
Copy Markdown
Contributor

What does this change do?

Lets a recipe version build on a Marketplace image that was imported into the catalog (#200), and makes sure images built that way get their license in the spoke account. It replaces #116, which brought its own Marketplace discovery.

@raphaho, in #200 you said you were happy to review this as a PR against main once #200 was merged, so here it is.

Packaging

  • A recipe version takes an optional parentImageId, the id of an imported Marketplace image. The image must match the recipe's platform and architecture, boot from /dev/sda1 and fit in the version's volume size. OS version is not checked, since imports take free text and recipes use a fixed list.
  • The version is pinned to the image's AMI in the build region. A version keeps working, and can still be updated, after its base image is retired by a newer import.
  • A built image carries the license part of its base's marketplaceMetadata: product code, ownership, licenseGrantAllowed, license ARN and home region. It does not carry regionalAmiIds, and it has no imageSource. Both image registration events pass the metadata on to publishing.
  • The image list response gains name, platform, architecture and OS version, which the base image picker in the recipe version wizard needs.

Publishing

  • The share decision returns a separate licenseDecision. A built image with license metadata is copied or shared like any other image and then licensed. A straight Marketplace import skips copy and share as before.
  • The seller's regional AMI ids are used only when imageSource is MARKETPLACE_PRODUCT.
  • Promote and restore now keep imageSource and marketplaceMetadata. They dropped both before, which also affected straight imports.

Type of change

  • Bug fix
  • New feature
  • Refactor / tech debt
  • Documentation
  • Infrastructure / CI

How was this tested?

Unit tests cover the recipe version handlers, the base image validation, image registration, the events and the share decision. The backend app suite passes, and so do the web app's type check, tests and lint. The state machine is covered by tests on the synthesised definition.

The Step Functions Local tests are updated, with two new cases for built images, but I could not run them locally. I have not run this against real AWS accounts yet.

Checklist

Notes for reviewers

  • The state machine is the part I would look at most closely. Every path now stores the AMI the spoke launches in $.copiedAmi and continues to one LicenseDecisionChoice. PassMarketplaceAmi moved to the start of the Marketplace path and PassLicenseGrant is gone, so the license states read the same field on every path.
  • The Image Service account's own license is not in this PR. When that account is separate from the hub, it needs a subscription or a grant to launch the base AMI. This is documented for now, since the grant authorization is tied to project accounts.
  • The service-to-service API has no parentImageId, so an update through it switches a version back to the default base image.
  • The frontend API client models are edited by hand in the generator's style, because I could not run the generator locally.
  • The update event fix from fix(packaging): publish updated parent image and volume size on update #203 is also in here and drops out when that merges.

Acknowledgment

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

An image built on a Marketplace AMI keeps its product code, so a spoke account needs the license to launch it. Such an image carries the license part of marketplaceMetadata without being a Marketplace import. The share decision now returns a separate license decision, and the AMI sharing state machine runs it at the end of every path: after copy, share or done for a built image, and directly for a straight import. Every path stores the AMI the spoke launches in $.copiedAmi, which the license states read.

The seller's regional AMI ids are used only when the image source is MARKETPLACE_PRODUCT, so a built image publishes its own AMI. Promote and restore keep imageSource and marketplaceMetadata.
…ages

A recipe version can take an imported Marketplace image as its base through an optional parentImageId. The image has to match the recipe's platform and architecture, have /dev/sda1 as root device and fit in the version's volume size. The version is pinned to the image's AMI in the build region.

The built image carries the product code, subscription ownership, grant capability, license configuration and home region of its base, and the image registration events pass them on to publishing.

The update event also carries the parent image and volume size from the update instead of the previous ones.

Closes awslabs#115
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Let recipe versions build on AWS Marketplace AMIs

1 participant