Skip to content

create_image_recipe async

create_image_recipe(
    name: ResourceName,
    semantic_version: WildcardVersionNumber,
    parent_image: NonEmptyString,
    client_token: ClientToken,
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
    description: Optional[NonEmptyString] = None,
    components: Optional[ComponentConfigurationList] = None,
    block_device_mappings: Optional[InstanceBlockDeviceMappings] = None,
    tags: Optional[TagMap] = None,
    working_directory: Optional[NonEmptyString] = None,
    additional_instance_configuration: Optional[AdditionalInstanceConfiguration] = None,
    ami_tags: Optional[TagMap] = None,
    ami_watermarks: Optional[AmiWatermarksList] = None,
    dry_run: Optional[Boolean] = None,
) -> CreateImageRecipeResponse

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

Parameters:

  • name (ResourceName) –

    The name of the image recipe. The recipe name, combined with the semantic version, must be unique to your account in each Amazon Web Services Region. Image Builder generates the image recipe ARN from a normalized form of the name, so names that differ only in case, spaces, or underscores count as the same name.

  • description (Optional[NonEmptyString], default: None ) –

    The description of the image recipe.

  • semantic_version (WildcardVersionNumber) –

    The semantic version of the image recipe. This version follows the semantic version syntax.

    The semantic version has four nodes: ../. You can assign values for the first three, and can filter on all of them.

    Assignment: For the first three nodes, you can assign any positive integer value, including zero. The upper limit is 2^30-1, or 1073741823, for each node. Image Builder automatically assigns the build number to the fourth node.

    Patterns: You can use any numeric pattern that adheres to the assignment requirements for the nodes that you can assign. For example, you might choose a software version pattern, such as 1.0.0, or a date, such as 2021.01.01.

  • components (Optional[ComponentConfigurationList], default: None ) –

    The components included in the image recipe. Components are optional. A recipe with no components bakes the base image without additional customization. You can specify each component only one time in a recipe. Components with a status of DEPRECATED or DISABLED can't be added to new recipes.

  • parent_image (NonEmptyString) –

    The base image for customizations specified in the image recipe. You can specify the parent image using one of the following options:

    • AMI ID

    • Image Builder image Amazon Resource Name (ARN)

    • Amazon Web Services Systems Manager (SSM) Parameter Store Parameter, prefixed by ssm:, followed by the parameter name or ARN.

    • Amazon Web Services Marketplace product ID

    If you enter an AMI ID or an SSM parameter that contains the AMI ID, you must have access to the AMI. The AMI must also be in the Region where you're creating the recipe.

  • block_device_mappings (Optional[InstanceBlockDeviceMappings], default: None ) –

    The block device mappings that Image Builder applies to the build instance and the output AMI. For example, you can override the size of the base image's root volume or attach additional EBS volumes.

  • tags (Optional[TagMap], default: None ) –

    The tags of the image recipe.

  • working_directory (Optional[NonEmptyString], default: None ) –

    The working directory used during build and test workflows. If you don't specify a working directory, Image Builder uses /tmp for Linux and macOS build instances, and C:/ for Windows build instances.

  • additional_instance_configuration (Optional[AdditionalInstanceConfiguration], default: None ) –

    The additional settings and launch scripts for your build instances.

  • ami_tags (Optional[TagMap], default: None ) –

    Tags that are applied to the AMI that Image Builder creates during the Build phase prior to image distribution.

  • ami_watermarks (Optional[AmiWatermarksList], default: None ) –

    The AMI watermark names to attach to the output AMI from this recipe. AMI watermarks are lineage markers. They automatically propagate to derivative AMIs when the source AMI is copied or distributed across Regions or accounts.

    AMI watermarks are supported only for image recipes. AMIs with watermarks cannot be made public.

  • client_token (ClientToken) –

    A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.

  • dry_run (Optional[Boolean], default: None ) –

    Validates the required permissions and request parameters without performing the operation. If validation succeeds, the operation returns a DryRunOperationException error response.

Raises:

Examples:

Create an image recipe The following example creates an image recipe that applies a custom component on top of the latest Amazon Linux 2023 base image.

>>> await client.create_image_recipe(name='my-example-recipe', semantic_version='1.0.0', description='An image recipe that installs my application on Amazon Linux 2023', parent_image='arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2023-x86/x.x.x', components=[{'componentArn': 'arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-component/1.0.0/1'}], client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE22222')
Create an image recipe with component parameters and block device mappings
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.
>>> await client.create_image_recipe(name='my-example-recipe', semantic_version='1.1.0', description='Installs a specific version of my application on Amazon Linux 2023 with a larger encrypted root volume', parent_image='arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2023-x86/x.x.x', components=[{'componentArn': 'arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-parameterized-component/1.0.0/1', 'parameters': [{'name': 'AppVersion', 'value': ['2.5.0']}]}], block_device_mappings=[{'deviceName': '/dev/xvda', 'ebs': {'volumeSize': 30, 'volumeType': 'gp3', 'encrypted': True, 'deleteOnTermination': True}}], client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE20202')
Source code in docs_src/capo_imagebuilder/_services/async_imagebuilder.py
async def create_image_recipe(
    self,
    name: "capo_imagebuilder.types.resource_name.ResourceName",
    semantic_version: "capo_imagebuilder.types.wildcard_version_number.WildcardVersionNumber",
    parent_image: "capo_imagebuilder.types.non_empty_string.NonEmptyString",
    client_token: "capo_imagebuilder.types.client_token.ClientToken",
    *,
    config_overrides: Optional[AsyncimagebuilderClientConfig] = None,
    description: Optional[
        "capo_imagebuilder.types.non_empty_string.NonEmptyString"
    ] = None,
    components: Optional[
        "capo_imagebuilder.types.component_configuration_list.ComponentConfigurationList"
    ] = None,
    block_device_mappings: Optional[
        "capo_imagebuilder.types.instance_block_device_mappings.InstanceBlockDeviceMappings"
    ] = None,
    tags: Optional["capo_imagebuilder.types.tag_map.TagMap"] = None,
    working_directory: Optional[
        "capo_imagebuilder.types.non_empty_string.NonEmptyString"
    ] = None,
    additional_instance_configuration: Optional[
        "capo_imagebuilder.types.additional_instance_configuration.AdditionalInstanceConfiguration"
    ] = None,
    ami_tags: Optional["capo_imagebuilder.types.tag_map.TagMap"] = None,
    ami_watermarks: Optional[
        "capo_imagebuilder.types.ami_watermarks_list.AmiWatermarksList"
    ] = None,
    dry_run: Optional["capo_imagebuilder.types.boolean.Boolean"] = None,
) -> (
    "capo_imagebuilder.types.create_image_recipe_response.CreateImageRecipeResponse"
):
    """<p>Creates a new image recipe. Image recipes define how images are configured, tested, and assessed.</p>

    Args:
        name: <p>The name of the image recipe. The recipe name, combined with the semantic version, must be unique to your account in each Amazon Web Services Region. Image Builder generates the image recipe ARN from a normalized form of the name, so names that differ only in case, spaces, or underscores count as the same name.</p>
        description: <p>The description of the image recipe.</p>
        semantic_version: <p>The semantic version of the image recipe. This version follows the semantic version syntax.</p> <note> <p>The semantic version has four nodes: <major>.<minor>.<patch>/<build>. You can assign values for the first three, and can filter on all of them.</p> <p> <b>Assignment:</b> For the first three nodes, you can assign any positive integer value, including zero. The upper limit is 2^30-1, or 1073741823, for each node. Image Builder automatically assigns the build number to the fourth node.</p> <p> <b>Patterns:</b> You can use any numeric pattern that adheres to the assignment requirements for the nodes that you can assign. For example, you might choose a software version pattern, such as 1.0.0, or a date, such as 2021.01.01.</p> </note>
        components: <p>The components included in the image recipe. Components are optional. A recipe with no components bakes the base image without additional customization. You can specify each component only one time in a recipe. Components with a status of <code>DEPRECATED</code> or <code>DISABLED</code> can't be added to new recipes.</p>
        parent_image: <p>The base image for customizations specified in the image recipe. You can specify the parent image using one of the following options:</p> <ul> <li> <p>AMI ID</p> </li> <li> <p>Image Builder image Amazon Resource Name (ARN)</p> </li> <li> <p>Amazon Web Services Systems Manager (SSM) Parameter Store Parameter, prefixed by <code>ssm:</code>, followed by the parameter name or ARN.</p> </li> <li> <p>Amazon Web Services Marketplace product ID</p> </li> </ul> <p>If you enter an AMI ID or an SSM parameter that contains the AMI ID, you must have access to the AMI. The AMI must also be in the Region where you're creating the recipe.</p>
        block_device_mappings: <p>The block device mappings that Image Builder applies to the build instance and the output AMI. For example, you can override the size of the base image's root volume or attach additional EBS volumes.</p>
        tags: <p>The tags of the image recipe.</p>
        working_directory: <p>The working directory used during build and test workflows. If you don't specify a working directory, Image Builder uses <code>/tmp</code> for Linux and macOS build instances, and <code>C:/</code> for Windows build instances.</p>
        additional_instance_configuration: <p>The additional settings and launch scripts for your build instances.</p>
        ami_tags: <p>Tags that are applied to the AMI that Image Builder creates during the Build phase prior to image distribution.</p>
        ami_watermarks: <p>The AMI watermark names to attach to the output AMI from this recipe. AMI watermarks are lineage markers. They automatically propagate to derivative AMIs when the source AMI is copied or distributed across Regions or accounts.</p> <note> <p>AMI watermarks are supported only for image recipes. AMIs with watermarks cannot be made public.</p> </note>
        client_token: <p>A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/APIReference/Run_Instance_Idempotency.html">Ensuring idempotency</a> in the <i>Amazon EC2 API Reference</i>.</p>
        dry_run: <p>Validates the required permissions and request parameters without performing the operation. If validation succeeds, the operation returns a <code>DryRunOperationException</code> error response.</p>

    Raises:
        capo_imagebuilder.errors.call_rate_limit_exceeded_exception.CallRateLimitExceededException: <p>You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.</p>
        capo_imagebuilder.errors.client_exception.ClientException: <p>A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.</p>
        capo_imagebuilder.errors.dry_run_operation_exception.DryRunOperationException: <p>The dry run operation of the resource was successful, and no resources or mutations were actually performed due to the dry run flag in the request.</p>
        capo_imagebuilder.errors.forbidden_exception.ForbiddenException: <p>You are not authorized to perform the requested operation.</p>
        capo_imagebuilder.errors.idempotent_parameter_mismatch_exception.IdempotentParameterMismatchException: <p>You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.</p>
        capo_imagebuilder.errors.invalid_request_exception.InvalidRequestException: <p>The request is malformed or otherwise invalid. Verify the request and try again.</p>
        capo_imagebuilder.errors.invalid_version_number_exception.InvalidVersionNumberException: <p>Your version number is out of bounds or does not follow the required syntax.</p>
        capo_imagebuilder.errors.resource_already_exists_exception.ResourceAlreadyExistsException: <p>The resource that you are trying to create already exists.</p>
        capo_imagebuilder.errors.resource_in_use_exception.ResourceInUseException: <p>The resource that you are trying to operate on is currently in use. Review the message details and retry later.</p>
        capo_imagebuilder.errors.service_exception.ServiceException: <p>An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.</p>
        capo_imagebuilder.errors.service_quota_exceeded_exception.ServiceQuotaExceededException: <p>You have exceeded the number of permitted resources or operations for this service. For service quotas, see <a href="https://docs.aws.amazon.com/general/latest/gr/imagebuilder.html#limits_imagebuilder">EC2 Image Builder endpoints and quotas</a>.</p>
        capo_imagebuilder.errors.service_unavailable_exception.ServiceUnavailableException: <p>The service is unable to process your request at this time.</p>
        capo_imagebuilder.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        Create an image recipe
        The following example creates an image recipe that applies a custom component on top of the latest Amazon Linux 2023 base image.

        >>> await client.create_image_recipe(name='my-example-recipe', semantic_version='1.0.0', description='An image recipe that installs my application on Amazon Linux 2023', parent_image='arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2023-x86/x.x.x', components=[{'componentArn': 'arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-component/1.0.0/1'}], client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE22222')
        Create an image recipe with component parameters and block device mappings
        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.

        >>> await client.create_image_recipe(name='my-example-recipe', semantic_version='1.1.0', description='Installs a specific version of my application on Amazon Linux 2023 with a larger encrypted root volume', parent_image='arn:aws:imagebuilder:us-west-2:aws:image/amazon-linux-2023-x86/x.x.x', components=[{'componentArn': 'arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-parameterized-component/1.0.0/1', 'parameters': [{'name': 'AppVersion', 'value': ['2.5.0']}]}], block_device_mappings=[{'deviceName': '/dev/xvda', 'ebs': {'volumeSize': 30, 'volumeType': 'gp3', 'encrypted': True, 'deleteOnTermination': True}}], client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE20202')
    """

    async def _handler(
        req: "AsyncOperationRequest[capo_imagebuilder.types.create_image_recipe_request.CreateImageRecipeRequest]",
    ) -> AsyncOperationResponse[
        "capo_imagebuilder.types.create_image_recipe_response.CreateImageRecipeResponse"
    ]:
        import capo_imagebuilder._operations.imagebuilder.create_image_recipe

        (
            output,
            http_response,
        ) = await capo_imagebuilder._operations.imagebuilder.create_image_recipe.async_create_image_recipe(
            req.options, req.input
        )
        return AsyncOperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateImageRecipe")
    )
    input_: capo_imagebuilder.types.create_image_recipe_request.CreateImageRecipeRequest = {
        "name": name,
        "semantic_version": semantic_version,
        "parent_image": parent_image,
        "client_token": client_token,
    }
    if description is not None:
        input_["description"] = description
    if components is not None:
        input_["components"] = components
    if block_device_mappings is not None:
        input_["block_device_mappings"] = block_device_mappings
    if tags is not None:
        input_["tags"] = tags
    if working_directory is not None:
        input_["working_directory"] = working_directory
    if additional_instance_configuration is not None:
        input_["additional_instance_configuration"] = (
            additional_instance_configuration
        )
    if ami_tags is not None:
        input_["ami_tags"] = ami_tags
    if ami_watermarks is not None:
        input_["ami_watermarks"] = ami_watermarks
    if dry_run is not None:
        input_["dry_run"] = dry_run

    response = await aexecute_pipeline(
        AsyncOperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    await response.response.aclose()
    return response.output