MachineImage

class aws_cdk.aws_ec2.MachineImage

Bases: object

Factory functions for standard Amazon Machine Image objects.

Static Methods

classmethod from_ssm_parameter(parameter_name, os, user_data=None)

An image specified in SSM parameter store that is automatically kept up-to-date.

This Machine Image automatically updates to the latest version on every deployment. Be aware this will cause your instances to be replaced when a new version of the image becomes available. Do not store stateful information on the instance if you are using this image.

Parameters
  • parameter_name (str) – The name of SSM parameter containing the AMi id.

  • os (OperatingSystemType) – The operating system type of the AMI.

  • user_data (Optional[UserData]) – optional user data for the given image.

Return type

IMachineImage

classmethod generic_linux(ami_map, *, user_data=None)

A Linux image where you specify the AMI ID for every region.

Parameters
  • ami_map (Mapping[str, str]) – For every region where you are deploying the stack, specify the AMI ID for that region.

  • user_data (Optional[UserData]) – Initial user data. Default: - Empty UserData for Linux machines

Return type

IMachineImage

classmethod generic_windows(ami_map, *, user_data=None)

A Windows image where you specify the AMI ID for every region.

Parameters
  • ami_map (Mapping[str, str]) – For every region where you are deploying the stack, specify the AMI ID for that region.

  • user_data (Optional[UserData]) – Initial user data. Default: - Empty UserData for Windows machines

Return type

IMachineImage

classmethod latest_amazon_linux(*, cpu_type=None, edition=None, generation=None, storage=None, user_data=None, virtualization=None)

An Amazon Linux image that is automatically kept up-to-date.

This Machine Image automatically updates to the latest version on every deployment. Be aware this will cause your instances to be replaced when a new version of the image becomes available. Do not store stateful information on the instance if you are using this image.

Parameters
  • cpu_type (Optional[AmazonLinuxCpuType]) – CPU Type. Default: X86_64

  • edition (Optional[AmazonLinuxEdition]) – What edition of Amazon Linux to use. Default: Standard

  • generation (Optional[AmazonLinuxGeneration]) – What generation of Amazon Linux to use. Default: AmazonLinux

  • storage (Optional[AmazonLinuxStorage]) – What storage backed image to use. Default: GeneralPurpose

  • user_data (Optional[UserData]) – Initial user data. Default: - Empty UserData for Linux machines

  • virtualization (Optional[AmazonLinuxVirt]) – Virtualization type. Default: HVM

Return type

IMachineImage

classmethod latest_windows(version, *, user_data=None)

A Windows image that is automatically kept up-to-date.

This Machine Image automatically updates to the latest version on every deployment. Be aware this will cause your instances to be replaced when a new version of the image becomes available. Do not store stateful information on the instance if you are using this image.

Parameters
  • version (WindowsVersion) –

  • user_data (Optional[UserData]) – Initial user data. Default: - Empty UserData for Windows machines

Return type

IMachineImage

classmethod lookup(*, name, filters=None, owners=None, user_data=None, windows=None)

Look up a shared Machine Image using DescribeImages.

The most recent, available, launchable image matching the given filter criteria will be used. Looking up AMIs may take a long time; specify as many filter criteria as possible to narrow down the search.

The AMI selected will be cached in cdk.context.json and the same value will be used on future runs. To refresh the AMI lookup, you will have to evict the value from the cache using the cdk context command. See https://docs.aws.amazon.com/cdk/latest/guide/context.html for more information.

Parameters
  • name (str) – Name of the image (may contain wildcards).

  • filters (Optional[Mapping[str, List[str]]]) – Additional filters on the AMI. Default: - No additional filters

  • owners (Optional[List[str]]) – Owner account IDs or aliases. Default: - All owners

  • user_data (Optional[UserData]) – Custom userdata for this image. Default: - Empty user data appropriate for the platform type

  • windows (Optional[bool]) – Look for Windows images. Default: false

Return type

IMachineImage