create_image
¶
create_image(
infrastructure_configuration_arn: InfrastructureConfigurationArn,
client_token: ClientToken,
*,
config_overrides: Optional[imagebuilderClientConfig] = None,
image_recipe_arn: Optional[ImageRecipeArn] = None,
container_recipe_arn: Optional[ContainerRecipeArn] = None,
distribution_configuration_arn: Optional[DistributionConfigurationArn] = None,
image_tests_configuration: Optional[ImageTestsConfiguration] = None,
enhanced_image_metadata_enabled: Optional[NullableBoolean] = None,
tags: Optional[TagMap] = None,
image_scanning_configuration: Optional[ImageScanningConfiguration] = None,
workflows: Optional[WorkflowConfigurationList] = None,
execution_role: Optional[RoleNameOrArn] = None,
logging_configuration: Optional[ImageLoggingConfiguration] = None,
) -> CreateImageResponse
Creates a new image along with all configured output resources defined in the distribution configuration. You must specify exactly one recipe for your image, using either a containerRecipeArn or an imageRecipeArn.
The response returns as soon as Image Builder creates the new image resource. The image build process runs asynchronously. To check its progress, call GetImage and check the image status.
Parameters:
-
image_recipe_arn(Optional[ImageRecipeArn], default:None) –The Amazon Resource Name (ARN) of the image recipe that defines how images are configured, tested, and assessed. You must specify either this property or
containerRecipeArn, but not both. -
container_recipe_arn(Optional[ContainerRecipeArn], default:None) –The Amazon Resource Name (ARN) of the container recipe that defines how images are configured and tested. You must specify either this property or
imageRecipeArn, but not both. -
distribution_configuration_arn(Optional[DistributionConfigurationArn], default:None) –The Amazon Resource Name (ARN) of the distribution configuration that defines and configures the outputs of the image build. If you don't specify a distribution configuration, Image Builder creates the output image only in the account and Amazon Web Services Region where the build runs.
-
infrastructure_configuration_arn(InfrastructureConfigurationArn) –The Amazon Resource Name (ARN) of the infrastructure configuration that defines the environment in which your image will be built and tested.
-
image_tests_configuration(Optional[ImageTestsConfiguration], default:None) –Settings that determine whether Image Builder runs tests on the image after building it. Image tests are enabled by default.
-
enhanced_image_metadata_enabled(Optional[NullableBoolean], default:None) –Specifies whether to collect additional information about the image being created, including the operating system (OS) version and package list. Defaults to
true. -
tags(Optional[TagMap], default:None) –The tags of the image.
-
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.
-
image_scanning_configuration(Optional[ImageScanningConfiguration], default:None) –Settings for vulnerability scans that Amazon Inspector runs during image creation. For AMI output, Amazon Inspector scans the test instance. For container output, Amazon Inspector scans the container image that Image Builder pushes to the Amazon ECR repository specified in
ecrConfiguration. -
workflows(Optional[WorkflowConfigurationList], default:None) –The array of workflow configuration objects for the build. If you specify workflows, they replace the default workflows that Image Builder otherwise runs for the build, and you must also provide an
executionRole. -
execution_role(Optional[RoleNameOrArn], default:None) –The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to perform workflow actions. This property is required if you specify
workflows. If you don't provide a role, Image Builder uses the Image Builder service-linked role in your account, and creates it if it doesn't exist. -
logging_configuration(Optional[ImageLoggingConfiguration], default:None) –The CloudWatch Logs log group where Image Builder sends the image build logs. If you specify a log group name outside of the
/aws/imagebuilder/namespace, you must also provide anexecutionRolethat has permission to write to that log group.
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.
-
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.
-
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 an image The following example creates a new image from the specified image recipe and infrastructure configuration.
>>> client.create_image(image_recipe_arn='arn:aws:imagebuilder:us-west-2:111122223333:image-recipe/my-example-recipe/1.0.0', infrastructure_configuration_arn='arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLEeeeee')
Create an image with custom build and parallel test workflows
The following example creates an image that uses your custom build and test workflows. It uses the Image Builder service-linked role as the execution role. Both test workflows are in the same parallel group, so they can run at the same time after the build workflow completes.
>>> client.create_image(image_recipe_arn='arn:aws:imagebuilder:us-west-2:111122223333:image-recipe/my-example-recipe/1.0.0', infrastructure_configuration_arn='arn:aws:imagebuilder:us-west-2:111122223333:infrastructure-configuration/my-example-infrastructure', workflows=[{'workflowArn': 'arn:aws:imagebuilder:us-west-2:111122223333:workflow/build/my-example-workflow/1.0.0/1'}, {'workflowArn': 'arn:aws:imagebuilder:us-west-2:111122223333:workflow/test/my-example-integration-tests/1.0.0/1', 'parallelGroup': 'post-build-tests'}, {'workflowArn': 'arn:aws:imagebuilder:us-west-2:111122223333:workflow/test/my-example-compliance-tests/1.0.0/1', 'parallelGroup': 'post-build-tests'}], execution_role='arn:aws:iam::111122223333:role/aws-service-role/imagebuilder.amazonaws.com/AWSServiceRoleForImageBuilder', client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE01234')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 | |