create_container_recipe
¶
create_container_recipe(
container_type: ContainerType,
name: ResourceName,
semantic_version: WildcardVersionNumber,
parent_image: NonEmptyString,
target_repository: TargetContainerRepository,
client_token: ClientToken,
*,
config_overrides: Optional[imagebuilderClientConfig] = None,
description: Optional[NonEmptyString] = None,
components: Optional[ComponentConfigurationList] = None,
instance_configuration: Optional[InstanceConfiguration] = None,
dockerfile_template_data: Optional[InlineDockerFileTemplate] = None,
dockerfile_template_uri: Optional[Uri] = None,
platform_override: Optional[Platform] = None,
image_os_version_override: Optional[NonEmptyString] = None,
tags: Optional[TagMap] = None,
working_directory: Optional[NonEmptyString] = None,
kms_key_id: Optional[NonEmptyString] = None,
dry_run: Optional[Boolean] = None,
) -> CreateContainerRecipeResponse
Creates a new container recipe. Container recipes define how images are configured, tested, and assessed.
Parameters:
-
container_type(ContainerType) –The type of container to create.
-
name(ResourceName) –The name of the container 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 container 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 container recipe.
-
semantic_version(WildcardVersionNumber) –The semantic version of the container 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 container recipe. You can specify each component only one time in a recipe.
-
instance_configuration(Optional[InstanceConfiguration], default:None) –A group of options that can be used to configure an instance for building and testing container images.
-
dockerfile_template_data(Optional[InlineDockerFileTemplate], default:None) –The Dockerfile template used to build your image, as an inline data blob. You must specify exactly one of the
dockerfileTemplateDataordockerfileTemplateUriproperties. For the contextual variables that the template can include, see Create a new version of a container recipe in the EC2 Image Builder User Guide. -
dockerfile_template_uri(Optional[Uri], default:None) –The Amazon S3 URI for the Dockerfile template that is used to build your container image. You must have permission to read the object. Image Builder reads the object once, when it creates the recipe, and stores its content in the recipe. Later changes to the S3 object don't affect the recipe. You must specify exactly one of the
dockerfileTemplateDataordockerfileTemplateUriproperties. -
platform_override(Optional[Platform], default:None) –Specifies the operating system platform when you use a custom base image. Container recipes support only the Linux and Windows platforms.
-
image_os_version_override(Optional[NonEmptyString], default:None) –Specifies the operating system version for the base image. Use this property only when the base image is a container image from a registry. When the base image is an Image Builder image, the operating system version comes from the parent image.
-
parent_image(NonEmptyString) –The base image for the container recipe. This can be an Image Builder image resource ARN or a container image URI from a registry, for example
amazonlinux:latest. -
tags(Optional[TagMap], default:None) –Tags that are attached to the container recipe.
-
working_directory(Optional[NonEmptyString], default:None) –The working directory for use during build and test workflows.
-
target_repository(TargetContainerRepository) –The destination repository for the container image. The Amazon ECR repository must already exist in the Amazon Web Services Region where the build runs.
-
kms_key_id(Optional[NonEmptyString], default:None) –The Amazon Resource Name (ARN) that uniquely identifies which KMS key is used to encrypt the Dockerfile template. This can be either the Key ARN or the Alias ARN. For more information, see Key identifiers (KeyId) in the Key Management Service Developer Guide.
-
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
DryRunOperationExceptionerror response.
Raises:
-
CallRateLimitExceededException–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.
-
ClientException–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.
-
DryRunOperationException–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.
-
ForbiddenException–You are not authorized to perform the requested operation.
-
IdempotentParameterMismatchException–You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.
-
InvalidRequestException–The request is malformed or otherwise invalid. Verify the request and try again.
-
InvalidVersionNumberException–Your version number is out of bounds or does not follow the required syntax.
-
ResourceAlreadyExistsException–The resource that you are trying to create already exists.
-
ResourceInUseException–The resource that you are trying to operate on is currently in use. Review the message details and retry later.
-
ServiceException–An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.
-
ServiceQuotaExceededException–You have exceeded the number of permitted resources or operations for this service. For service quotas, see EC2 Image Builder endpoints and quotas.
-
ServiceUnavailableException–The service is unable to process your request at this time.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Create a container recipe with a custom build instance configuration The following example creates a container recipe that customizes the Amazon EC2 instance that builds the container image. The build instance launches from an Amazon ECS-optimized instance image and uses a 40 GiB gp3 volume.
>>> client.create_container_recipe(container_type='DOCKER', name='my-example-container-recipe', semantic_version='1.1.0', description='A container recipe that builds on an ECS-optimized instance image with a larger build volume', parent_image='amazonlinux:latest', components=[{'componentArn': 'arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-container-component/1.0.0/1'}], instance_configuration={'image': 'ami-1234567890abcdef0', 'blockDeviceMappings': [{'deviceName': '/dev/xvda', 'ebs': {'volumeSize': 40, 'volumeType': 'gp3', 'deleteOnTermination': True}}]}, dockerfile_template_data='FROM {{{ imagebuilder:parentImage }}}\n{{{ imagebuilder:environments }}}\n{{{ imagebuilder:components }}}\n', target_repository={'service': 'ECR', 'repositoryName': 'my-example-container-repo'}, client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE40404')
Create a container recipe with an inline Dockerfile template
The following example creates a Docker container recipe that applies one build component, using the latest Amazon Linux container image as the parent and an existing ECR repository as the target.
>>> client.create_container_recipe(container_type='DOCKER', name='my-example-container-recipe', semantic_version='1.0.0', parent_image='amazonlinux:latest', components=[{'componentArn': 'arn:aws:imagebuilder:us-west-2:111122223333:component/my-example-container-component/1.0.0/1'}], dockerfile_template_data='FROM {{{ imagebuilder:parentImage }}}\n{{{ imagebuilder:environments }}}\n{{{ imagebuilder:components }}}\n', target_repository={'service': 'ECR', 'repositoryName': 'my-example-container-repo'}, client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE99999')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 | |