create_image_recipe
¶
create_image_recipe(
name: ResourceName,
semantic_version: WildcardVersionNumber,
parent_image: NonEmptyString,
client_token: ClientToken,
*,
config_overrides: Optional[imagebuilderClientConfig] = 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
DEPRECATEDorDISABLEDcan'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
/tmpfor Linux and macOS build instances, andC:/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
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 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.
>>> 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.
>>> 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/imagebuilder.py
1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 | |