class MachineImage
| Language | Type name | 
|---|---|
  .NET | Amazon.CDK.AWS.EC2.MachineImage | 
  Java | software.amazon.awscdk.services.ec2.MachineImage | 
  Python | aws_cdk.aws_ec2.MachineImage | 
  TypeScript (source) | @aws-cdk/aws-ec2 » MachineImage | 
Factory functions for standard Amazon Machine Image objects.
Example
declare const vpc: ec2.Vpc;
const template = new ec2.LaunchTemplate(this, 'LaunchTemplate', {
  machineImage: ec2.MachineImage.latestAmazonLinux(),
  securityGroup: new ec2.SecurityGroup(this, 'LaunchTemplateSG', {
    vpc: vpc,
  }),
});
Initializer
new MachineImage()
Methods
| Name | Description | 
|---|---|
| static from | An image specified in SSM parameter store that is automatically kept up-to-date. | 
| static from | An image specified in SSM parameter store. | 
| static generic | A Linux image where you specify the AMI ID for every region. | 
| static generic | A Windows image where you specify the AMI ID for every region. | 
| static latest | An Amazon Linux image that is automatically kept up-to-date. | 
| static latest | A Windows image that is automatically kept up-to-date. | 
| static lookup(props) | Look up a shared Machine Image using DescribeImages. | 
static fromSSMParameter(parameterName, os, userData?) 
public static fromSSMParameter(parameterName: string, os: OperatingSystemType, userData?: UserData): IMachineImage
⚠️ Deprecated: Use MachineImage.fromSsmParameter() instead
Parameters
- parameterName 
string— The name of SSM parameter containing the AMi id. - os 
Operating— The operating system type of the AMI.System Type  - userData 
User— optional user data for the given image.Data  
Returns
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.
static fromSsmParameter(parameterName, options?)  
public static fromSsmParameter(parameterName: string, options?: SsmParameterImageOptions): IMachineImage
Parameters
- parameterName 
string - options 
SsmParameter Image Options  
Returns
An image specified in SSM parameter store.
By default, the SSM parameter is refreshed at every deployment, causing your instances to be replaced whenever a new version of the AMI is released.
Pass { cachedInContext: true } to keep the AMI ID stable. If you do, you
will have to remember to periodically invalidate the context to refresh
to the newest AMI ID.
static genericLinux(amiMap, props?) 
public static genericLinux(amiMap: { [string]: string }, props?: GenericLinuxImageProps): IMachineImage
Parameters
- amiMap 
{ [string]: string }— For every region where you are deploying the stack, specify the AMI ID for that region. - props 
Generic— Customize the image by supplying additional props.Linux Image Props  
Returns
A Linux image where you specify the AMI ID for every region.
static genericWindows(amiMap, props?) 
public static genericWindows(amiMap: { [string]: string }, props?: GenericWindowsImageProps): IMachineImage
Parameters
- amiMap 
{ [string]: string }— For every region where you are deploying the stack, specify the AMI ID for that region. - props 
Generic— Customize the image by supplying additional props.Windows Image Props  
Returns
A Windows image where you specify the AMI ID for every region.
static latestAmazonLinux(props?)  
public static latestAmazonLinux(props?: AmazonLinuxImageProps): IMachineImage
Parameters
- props 
AmazonLinux Image Props  
Returns
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.
static latestWindows(version, props?) 
public static latestWindows(version: WindowsVersion, props?: WindowsImageProps): IMachineImage
Parameters
- version 
WindowsVersion  - props 
WindowsImage Props  
Returns
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.
static lookup(props)
public static lookup(props: LookupMachineImageProps): IMachineImage
Parameters
- props 
LookupMachine Image Props  
Returns
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.
This function can not be used in environment-agnostic stacks.

 .NET
 Java
 Python
 TypeScript (