CfnImageRecipe
- class aws_cdk.aws_imagebuilder.CfnImageRecipe(scope, id, *, components, name, parent_image, version, additional_instance_configuration=None, block_device_mappings=None, description=None, tags=None, working_directory=None)
Bases:
CfnResource
A CloudFormation
AWS::ImageBuilder::ImageRecipe
.An Image Builder image recipe is a document that defines the base image and the components to be applied to the base image to produce the desired configuration for the output image. You can use an image recipe to duplicate builds. Image Builder image recipes can be shared, branched, and edited using the console wizard, the AWS CLI , or the API. You can use image recipes with your version control software to maintain shareable versioned image recipes.
- CloudformationResource:
AWS::ImageBuilder::ImageRecipe
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder cfn_image_recipe = imagebuilder.CfnImageRecipe(self, "MyCfnImageRecipe", components=[imagebuilder.CfnImageRecipe.ComponentConfigurationProperty( component_arn="componentArn", parameters=[imagebuilder.CfnImageRecipe.ComponentParameterProperty( name="name", value=["value"] )] )], name="name", parent_image="parentImage", version="version", # the properties below are optional additional_instance_configuration=imagebuilder.CfnImageRecipe.AdditionalInstanceConfigurationProperty( systems_manager_agent=imagebuilder.CfnImageRecipe.SystemsManagerAgentProperty( uninstall_after_build=False ), user_data_override="userDataOverride" ), block_device_mappings=[imagebuilder.CfnImageRecipe.InstanceBlockDeviceMappingProperty( device_name="deviceName", ebs=imagebuilder.CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty( delete_on_termination=False, encrypted=False, iops=123, kms_key_id="kmsKeyId", snapshot_id="snapshotId", throughput=123, volume_size=123, volume_type="volumeType" ), no_device="noDevice", virtual_name="virtualName" )], description="description", tags={ "tags_key": "tags" }, working_directory="workingDirectory" )
Create a new
AWS::ImageBuilder::ImageRecipe
.- Parameters:
scope (
Construct
) –scope in which this resource is defined.
id (
str
) –scoped id of the resource.
components (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,ComponentConfigurationProperty
,Dict
[str
,Any
]]]]) – The components of the image recipe. Components are orchestration documents that define a sequence of steps for downloading, installing, configuring, and testing software packages. They also define validation and security hardening steps. A component is defined using a YAML document format.name (
str
) – The name of the image recipe.parent_image (
str
) – The parent image of the image recipe. The string must be either an Image ARN or an AMI ID.version (
str
) – The semantic version of the image recipe.additional_instance_configuration (
Union
[IResolvable
,AdditionalInstanceConfigurationProperty
,Dict
[str
,Any
],None
]) – Before you create a new AMI, Image Builder launches temporary Amazon EC2 instances to build and test your image configuration. Instance configuration adds a layer of control over those instances. You can define settings and add scripts to run when an instance is launched from your AMI.block_device_mappings (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,InstanceBlockDeviceMappingProperty
,Dict
[str
,Any
]]],None
]) – The block device mappings to apply when creating images from this recipe.description (
Optional
[str
]) – The description of the image recipe.tags (
Optional
[Mapping
[str
,str
]]) – The tags of the image recipe.working_directory (
Optional
[str
]) – The working directory to be used during build and test workflows.
Methods
- add_deletion_override(path)
Syntactic sugar for
addOverride(path, undefined)
.- Parameters:
path (
str
) – The path of the value to delete.- Return type:
None
- add_depends_on(target)
Indicates that this resource depends on another resource and cannot be provisioned unless the other resource has been successfully provisioned.
This can be used for resources across stacks (or nested stack) boundaries and the dependency will automatically be transferred to the relevant scope.
- Parameters:
target (
CfnResource
)- Return type:
None
- add_metadata(key, value)
Add a value to the CloudFormation Resource Metadata.
- Parameters:
key (
str
)value (
Any
)
- See:
- Return type:
None
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- add_override(path, value)
Adds an override to the synthesized CloudFormation resource.
To add a property override, either use
addPropertyOverride
or prefixpath
with “Properties.” (i.e.Properties.TopicName
).If the override is nested, separate each nested level using a dot (.) in the path parameter. If there is an array as part of the nesting, specify the index in the path.
To include a literal
.
in the property name, prefix with a\
. In most programming languages you will need to write this as"\\."
because the\
itself will need to be escaped.For example:
cfn_resource.add_override("Properties.GlobalSecondaryIndexes.0.Projection.NonKeyAttributes", ["myattribute"]) cfn_resource.add_override("Properties.GlobalSecondaryIndexes.1.ProjectionType", "INCLUDE")
would add the overrides Example:
"Properties": { "GlobalSecondaryIndexes": [ { "Projection": { "NonKeyAttributes": [ "myattribute" ] ... } ... }, { "ProjectionType": "INCLUDE" ... }, ] ... }
The
value
argument toaddOverride
will not be processed or translated in any way. Pass raw JSON values in here with the correct capitalization for CloudFormation. If you pass CDK classes or structs, they will be rendered with lowercased key names, and CloudFormation will reject the template.- Parameters:
path (
str
) –The path of the property, you can use dot notation to override values in complex types. Any intermdediate keys will be created as needed.
value (
Any
) –The value. Could be primitive or complex.
- Return type:
None
- add_property_deletion_override(property_path)
Adds an override that deletes the value of a property from the resource definition.
- Parameters:
property_path (
str
) – The path to the property.- Return type:
None
- add_property_override(property_path, value)
Adds an override to a resource property.
Syntactic sugar for
addOverride("Properties.<...>", value)
.- Parameters:
property_path (
str
) – The path of the property.value (
Any
) – The value.
- Return type:
None
- apply_removal_policy(policy=None, *, apply_to_update_replace_policy=None, default=None)
Sets the deletion policy of the resource based on the removal policy specified.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you’ve removed it from the CDK application or because you’ve made a change that requires the resource to be replaced.
The resource can be deleted (
RemovalPolicy.DESTROY
), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN
).- Parameters:
policy (
Optional
[RemovalPolicy
])apply_to_update_replace_policy (
Optional
[bool
]) – Apply the same deletion policy to the resource’s “UpdateReplacePolicy”. Default: truedefault (
Optional
[RemovalPolicy
]) – The default policy to apply in case the removal policy is not defined. Default: - Default value is resource specific. To determine the default value for a resoure, please consult that specific resource’s documentation.
- Return type:
None
- get_att(attribute_name)
Returns a token for an runtime attribute of this resource.
Ideally, use generated attribute accessors (e.g.
resource.arn
), but this can be used for future compatibility in case there is no generated attribute.- Parameters:
attribute_name (
str
) – The name of the attribute.- Return type:
- get_metadata(key)
Retrieve a value value from the CloudFormation Resource Metadata.
- Parameters:
key (
str
)- See:
- Return type:
Any
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/metadata-section-structure.html
Note that this is a different set of metadata from CDK node metadata; this metadata ends up in the stack template under the resource, whereas CDK node metadata ends up in the Cloud Assembly.
- inspect(inspector)
Examines the CloudFormation resource and discloses attributes.
- Parameters:
inspector (
TreeInspector
) –tree inspector to collect and process attributes.
- Return type:
None
- override_logical_id(new_logical_id)
Overrides the auto-generated logical ID with a specific ID.
- Parameters:
new_logical_id (
str
) – The new logical ID to use for this stack element.- Return type:
None
- to_string()
Returns a string representation of this construct.
- Return type:
str
- Returns:
a string representation of this resource
Attributes
- CFN_RESOURCE_TYPE_NAME = 'AWS::ImageBuilder::ImageRecipe'
- additional_instance_configuration
Before you create a new AMI, Image Builder launches temporary Amazon EC2 instances to build and test your image configuration.
Instance configuration adds a layer of control over those instances. You can define settings and add scripts to run when an instance is launched from your AMI.
- attr_arn
Returns the Amazon Resource Name (ARN) of the image recipe.
For example,
arn:aws:imagebuilder:us-east-1:123456789012:image-recipe/mybasicrecipe/2019.12.03
.- CloudformationAttribute:
Arn
- attr_name
The name of the image recipe.
- CloudformationAttribute:
Name
- block_device_mappings
The block device mappings to apply when creating images from this recipe.
- cfn_options
Options for this resource, such as condition, update policy etc.
- cfn_resource_type
AWS resource type.
- components
The components of the image recipe.
Components are orchestration documents that define a sequence of steps for downloading, installing, configuring, and testing software packages. They also define validation and security hardening steps. A component is defined using a YAML document format.
- creation_stack
return:
the stack trace of the point where this Resource was created from, sourced from the +metadata+ entry typed +aws:cdk:logicalId+, and with the bottom-most node +internal+ entries filtered.
- description
The description of the image recipe.
- logical_id
The logical ID for this CloudFormation stack element.
The logical ID of the element is calculated from the path of the resource node in the construct tree.
To override this value, use
overrideLogicalId(newLogicalId)
.- Returns:
the logical ID as a stringified token. This value will only get resolved during synthesis.
- name
The name of the image recipe.
- node
The construct tree node associated with this construct.
- parent_image
The parent image of the image recipe.
The string must be either an Image ARN or an AMI ID.
- ref
Return a string that will be resolved to a CloudFormation
{ Ref }
for this element.If, by any chance, the intrinsic reference of a resource is not a string, you could coerce it to an IResolvable through
Lazy.any({ produce: resource.ref })
.
- stack
The stack in which this element is defined.
CfnElements must be defined within a stack scope (directly or indirectly).
- tags
The tags of the image recipe.
- version
The semantic version of the image recipe.
- working_directory
The working directory to be used during build and test workflows.
Static Methods
- classmethod is_cfn_element(x)
Returns
true
if a construct is a stack element (i.e. part of the synthesized cloudformation template).Uses duck-typing instead of
instanceof
to allow stack elements from different versions of this library to be included in the same stack.- Parameters:
x (
Any
)- Return type:
bool
- Returns:
The construct as a stack element or undefined if it is not a stack element.
- classmethod is_cfn_resource(construct)
Check whether the given construct is a CfnResource.
- Parameters:
construct (
IConstruct
)- Return type:
bool
- classmethod is_construct(x)
Return whether the given object is a Construct.
- Parameters:
x (
Any
)- Return type:
bool
AdditionalInstanceConfigurationProperty
- class CfnImageRecipe.AdditionalInstanceConfigurationProperty(*, systems_manager_agent=None, user_data_override=None)
Bases:
object
In addition to your infrastructure configuration, these settings provide an extra layer of control over your build instances.
You can also specify commands to run on launch for all of your build instances.
Image Builder does not automatically install the Systems Manager agent on Windows instances. If your base image includes the Systems Manager agent, then the AMI that you create will also include the agent. For Linux instances, if the base image does not already include the Systems Manager agent, Image Builder installs it. For Linux instances where Image Builder installs the Systems Manager agent, you can choose whether to keep it for the AMI that you create.
- Parameters:
systems_manager_agent (
Union
[IResolvable
,SystemsManagerAgentProperty
,Dict
[str
,Any
],None
]) – Contains settings for the Systems Manager agent on your build instance.user_data_override (
Optional
[str
]) – Use this property to provide commands or a command script to run when you launch your build instance. The userDataOverride property replaces any commands that Image Builder might have added to ensure that Systems Manager is installed on your Linux build instance. If you override the user data, make sure that you add commands to install Systems Manager, if it is not pre-installed on your base image. .. epigraph:: The user data is always base 64 encoded. For example, the following commands are encoded asIyEvYmluL2Jhc2gKbWtkaXIgLXAgL3Zhci9iYi8KdG91Y2ggL3Zhci$
: #!/bin/bash mkdir -p /var/bb/ touch /var
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder additional_instance_configuration_property = imagebuilder.CfnImageRecipe.AdditionalInstanceConfigurationProperty( systems_manager_agent=imagebuilder.CfnImageRecipe.SystemsManagerAgentProperty( uninstall_after_build=False ), user_data_override="userDataOverride" )
Attributes
- systems_manager_agent
Contains settings for the Systems Manager agent on your build instance.
- user_data_override
Use this property to provide commands or a command script to run when you launch your build instance.
The userDataOverride property replaces any commands that Image Builder might have added to ensure that Systems Manager is installed on your Linux build instance. If you override the user data, make sure that you add commands to install Systems Manager, if it is not pre-installed on your base image. .. epigraph:
The user data is always base 64 encoded. For example, the following commands are encoded as ``IyEvYmluL2Jhc2gKbWtkaXIgLXAgL3Zhci9iYi8KdG91Y2ggL3Zhci$`` : *#!/bin/bash* mkdir -p /var/bb/ touch /var
ComponentConfigurationProperty
- class CfnImageRecipe.ComponentConfigurationProperty(*, component_arn=None, parameters=None)
Bases:
object
Configuration details of the component.
- Parameters:
component_arn (
Optional
[str
]) – The Amazon Resource Name (ARN) of the component.parameters (
Union
[IResolvable
,Sequence
[Union
[IResolvable
,ComponentParameterProperty
,Dict
[str
,Any
]]],None
]) – A group of parameter settings that Image Builder uses to configure the component for a specific recipe.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder component_configuration_property = imagebuilder.CfnImageRecipe.ComponentConfigurationProperty( component_arn="componentArn", parameters=[imagebuilder.CfnImageRecipe.ComponentParameterProperty( name="name", value=["value"] )] )
Attributes
- component_arn
The Amazon Resource Name (ARN) of the component.
- parameters
A group of parameter settings that Image Builder uses to configure the component for a specific recipe.
ComponentParameterProperty
- class CfnImageRecipe.ComponentParameterProperty(*, name, value)
Bases:
object
Contains a key/value pair that sets the named component parameter.
- Parameters:
name (
str
) – The name of the component parameter to set.value (
Sequence
[str
]) – Sets the value for the named component parameter.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder component_parameter_property = imagebuilder.CfnImageRecipe.ComponentParameterProperty( name="name", value=["value"] )
Attributes
- name
The name of the component parameter to set.
- value
Sets the value for the named component parameter.
EbsInstanceBlockDeviceSpecificationProperty
- class CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty(*, delete_on_termination=None, encrypted=None, iops=None, kms_key_id=None, snapshot_id=None, throughput=None, volume_size=None, volume_type=None)
Bases:
object
The image recipe EBS instance block device specification includes the Amazon EBS-specific block device mapping specifications for the image.
- Parameters:
delete_on_termination (
Union
[bool
,IResolvable
,None
]) – Configures delete on termination of the associated device.encrypted (
Union
[bool
,IResolvable
,None
]) – Use to configure device encryption.iops (
Union
[int
,float
,None
]) – Use to configure device IOPS.kms_key_id (
Optional
[str
]) – Use to configure the KMS key to use when encrypting the device.snapshot_id (
Optional
[str
]) – The snapshot that defines the device contents.throughput (
Union
[int
,float
,None
]) – For GP3 volumes only – The throughput in MiB/s that the volume supports.volume_size (
Union
[int
,float
,None
]) – Overrides the volume size of the device.volume_type (
Optional
[str
]) – Overrides the volume type of the device.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder ebs_instance_block_device_specification_property = imagebuilder.CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty( delete_on_termination=False, encrypted=False, iops=123, kms_key_id="kmsKeyId", snapshot_id="snapshotId", throughput=123, volume_size=123, volume_type="volumeType" )
Attributes
- delete_on_termination
Configures delete on termination of the associated device.
- encrypted
Use to configure device encryption.
- iops
Use to configure device IOPS.
- kms_key_id
Use to configure the KMS key to use when encrypting the device.
- snapshot_id
The snapshot that defines the device contents.
- throughput
For GP3 volumes only – The throughput in MiB/s that the volume supports.
- volume_size
Overrides the volume size of the device.
- volume_type
Overrides the volume type of the device.
InstanceBlockDeviceMappingProperty
- class CfnImageRecipe.InstanceBlockDeviceMappingProperty(*, device_name=None, ebs=None, no_device=None, virtual_name=None)
Bases:
object
Defines block device mappings for the instance used to configure your image.
- Parameters:
device_name (
Optional
[str
]) – The device to which these mappings apply.ebs (
Union
[IResolvable
,EbsInstanceBlockDeviceSpecificationProperty
,Dict
[str
,Any
],None
]) – Use to manage Amazon EBS-specific configuration for this mapping.no_device (
Optional
[str
]) – Enter an empty string to remove a mapping from the parent image. The following is an example of an empty string value in theNoDevice
field.NoDevice:""
virtual_name (
Optional
[str
]) – Manages the instance ephemeral devices.
- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder instance_block_device_mapping_property = imagebuilder.CfnImageRecipe.InstanceBlockDeviceMappingProperty( device_name="deviceName", ebs=imagebuilder.CfnImageRecipe.EbsInstanceBlockDeviceSpecificationProperty( delete_on_termination=False, encrypted=False, iops=123, kms_key_id="kmsKeyId", snapshot_id="snapshotId", throughput=123, volume_size=123, volume_type="volumeType" ), no_device="noDevice", virtual_name="virtualName" )
Attributes
- device_name
The device to which these mappings apply.
- ebs
Use to manage Amazon EBS-specific configuration for this mapping.
- no_device
Enter an empty string to remove a mapping from the parent image.
The following is an example of an empty string value in the
NoDevice
field.NoDevice:""
- virtual_name
Manages the instance ephemeral devices.
SystemsManagerAgentProperty
- class CfnImageRecipe.SystemsManagerAgentProperty(*, uninstall_after_build=None)
Bases:
object
Contains settings for the Systems Manager agent on your build instance.
- Parameters:
uninstall_after_build (
Union
[bool
,IResolvable
,None
]) – Controls whether the Systems Manager agent is removed from your final build image, prior to creating the new AMI. If this is set to true, then the agent is removed from the final image. If it’s set to false, then the agent is left in, so that it is included in the new AMI. The default value is false.- Link:
- ExampleMetadata:
fixture=_generated
Example:
# The code below shows an example of how to instantiate this type. # The values are placeholders you should change. import aws_cdk.aws_imagebuilder as imagebuilder systems_manager_agent_property = imagebuilder.CfnImageRecipe.SystemsManagerAgentProperty( uninstall_after_build=False )
Attributes
- uninstall_after_build
Controls whether the Systems Manager agent is removed from your final build image, prior to creating the new AMI.
If this is set to true, then the agent is removed from the final image. If it’s set to false, then the agent is left in, so that it is included in the new AMI. The default value is false.