createComponent

Creates a new component that can be used to build, validate, test, and assess your image. The component is based on a YAML document that you specify using exactly one of the following methods:

  • Inline, using the data property in the request body.

  • A URL that points to a YAML document file stored in Amazon S3, using the uri property in the request body.

Image Builder determines the component type from the document. If the document contains a single phase named test, the component type is TEST. Otherwise, the component type is BUILD.

Samples

// The following example creates a component from a YAML definition document that s stored in an Amazon
// S3 bucket. The definition document for this component includes an AppVersion parameter that recipes
// can set when they include the component.
val resp = imagebuilderClient.createComponent {
    name = "my-example-parameterized-component"
    semanticVersion = "1.0.0"
    description = "Installs a configurable version of my application"
    platform = Platform.fromValue("Linux")
    uri = "s3://amzn-s3-demo-bucket/components/install-my-app.yaml"
    clientToken = "a1b2c3d4-5678-90ab-cdef-EXAMPLE10101"
}
// The following example creates a build component from a YAML document provided inline in the request.
val resp = imagebuilderClient.createComponent {
    name = "my-example-component"
    semanticVersion = "1.0.0"
    description = "Installs the latest version of my application"
    platform = Platform.fromValue("Linux")
    data = "name: InstallMyApp\ndescription: Installs my application\nschemaVersion: 1.0\nphases:\n  - name: build\n    steps:\n      - name: InstallApp\n        action: ExecuteBash\n        inputs:\n          commands:\n            - sudo yum -y install my-app\n"
    clientToken = "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111"
}