createImageRecipe

Creates a new image recipe. Image recipes define how images are configured, tested, and assessed.

Samples

// The following example creates an image recipe that applies a custom component on top of the latest
// Amazon Linux 2023 base image.
val resp = imagebuilderClient.createImageRecipe {
    name = "my-example-recipe"
    semanticVersion = "1.0.0"
    description = "An image recipe that installs my application on Amazon Linux 2023"
    parentImage = "arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2023-x86/x.x.x"
    components = listOf<ComponentConfiguration>(
        ComponentConfiguration {
            componentArn = "arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-component/1.0.0/1"
        }            
    )
    clientToken = "a1b2c3d4-5678-90ab-cdef-EXAMPLE22222"
}
// The following example creates an image recipe that configures its components and storage. The
// AppVersion component parameter selects the application version to install. The block device mapping increases
// the root volume to an encrypted 30 GiB gp3 volume.
val resp = imagebuilderClient.createImageRecipe {
    name = "my-example-recipe"
    semanticVersion = "1.1.0"
    description = "Installs a specific version of my application on Amazon Linux 2023 with a larger encrypted root volume"
    parentImage = "arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2023-x86/x.x.x"
    components = listOf<ComponentConfiguration>(
        ComponentConfiguration {
            componentArn = "arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-parameterized-component/1.0.0/1"
            parameters = listOf<ComponentParameter>(
                ComponentParameter {
                    name = "AppVersion"
                    value = listOf<String>(
                        "2.5.0"
                    )
                }                    
            )
        }            
    )
    blockDeviceMappings = listOf<InstanceBlockDeviceMapping>(
        InstanceBlockDeviceMapping {
            deviceName = "/dev/xvda"
            ebs = EbsInstanceBlockDeviceSpecification {
                volumeSize = 30
                volumeType = EbsVolumeType.fromValue("gp3")
                encrypted = true
                deleteOnTermination = true
            }
        }            
    )
    clientToken = "a1b2c3d4-5678-90ab-cdef-EXAMPLE20202"
}