Class MachineImage
Factory functions for standard Amazon Machine Image objects.
Inheritance
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.AWS.EC2.dll
Syntax (csharp)
public abstract class MachineImage : DeputyBase
Syntax (vb)
Public MustInherit Class MachineImage
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
var template = new LaunchTemplate(this, "LaunchTemplate", new LaunchTemplateProps {
MachineImage = MachineImage.LatestAmazonLinux(),
SecurityGroup = new SecurityGroup(this, "LaunchTemplateSG", new SecurityGroupProps {
Vpc = vpc
})
});
Synopsis
Constructors
MachineImage() | |
MachineImage(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
MachineImage(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
FromSsmParameter(String, ISsmParameterImageOptions) | An image specified in SSM parameter store. |
FromSSMParameter(String, OperatingSystemType, UserData) | (deprecated) An image specified in SSM parameter store that is automatically kept up-to-date. |
GenericLinux(IDictionary<String, String>, IGenericLinuxImageProps) | A Linux image where you specify the AMI ID for every region. |
GenericWindows(IDictionary<String, String>, IGenericWindowsImageProps) | A Windows image where you specify the AMI ID for every region. |
LatestAmazonLinux(IAmazonLinuxImageProps) | An Amazon Linux image that is automatically kept up-to-date. |
LatestWindows(WindowsVersion, IWindowsImageProps) | A Windows image that is automatically kept up-to-date. |
Lookup(ILookupMachineImageProps) | Look up a shared Machine Image using DescribeImages. |
Constructors
MachineImage()
protected MachineImage()
MachineImage(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected MachineImage(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
MachineImage(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected MachineImage(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
FromSsmParameter(String, ISsmParameterImageOptions)
An image specified in SSM parameter store.
public static IMachineImage FromSsmParameter(string parameterName, ISsmParameterImageOptions options = null)
Parameters
- parameterName System.String
- options ISsmParameterImageOptions
Returns
Remarks
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.
FromSSMParameter(String, OperatingSystemType, UserData)
(deprecated) An image specified in SSM parameter store that is automatically kept up-to-date.
public static IMachineImage FromSSMParameter(string parameterName, OperatingSystemType os, UserData userData = null)
Parameters
- parameterName System.String
The name of SSM parameter containing the AMi id.
- os OperatingSystemType
The operating system type of the AMI.
- userData UserData
optional user data for the given image.
Returns
Remarks
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.
Stability: Deprecated
GenericLinux(IDictionary<String, String>, IGenericLinuxImageProps)
A Linux image where you specify the AMI ID for every region.
public static IMachineImage GenericLinux(IDictionary<string, string> amiMap, IGenericLinuxImageProps props = null)
Parameters
- amiMap System.Collections.Generic.IDictionary<System.String, System.String>
For every region where you are deploying the stack, specify the AMI ID for that region.
- props IGenericLinuxImageProps
Customize the image by supplying additional props.
Returns
GenericWindows(IDictionary<String, String>, IGenericWindowsImageProps)
A Windows image where you specify the AMI ID for every region.
public static IMachineImage GenericWindows(IDictionary<string, string> amiMap, IGenericWindowsImageProps props = null)
Parameters
- amiMap System.Collections.Generic.IDictionary<System.String, System.String>
For every region where you are deploying the stack, specify the AMI ID for that region.
- props IGenericWindowsImageProps
Customize the image by supplying additional props.
Returns
LatestAmazonLinux(IAmazonLinuxImageProps)
An Amazon Linux image that is automatically kept up-to-date.
public static IMachineImage LatestAmazonLinux(IAmazonLinuxImageProps props = null)
Parameters
- props IAmazonLinuxImageProps
Returns
Remarks
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.
LatestWindows(WindowsVersion, IWindowsImageProps)
A Windows image that is automatically kept up-to-date.
public static IMachineImage LatestWindows(WindowsVersion version, IWindowsImageProps props = null)
Parameters
- version WindowsVersion
- props IWindowsImageProps
Returns
Remarks
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.
Lookup(ILookupMachineImageProps)
Look up a shared Machine Image using DescribeImages.
public static IMachineImage Lookup(ILookupMachineImageProps props)
Parameters
- props ILookupMachineImageProps
Returns
Remarks
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.