Class MachineImage
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Example:
Vpc vpc; SecurityGroup mySecurityGroup = SecurityGroup.Builder.create(this, "SecurityGroup").vpc(vpc).build(); AutoScalingGroup.Builder.create(this, "ASG") .vpc(vpc) .instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO)) .machineImage(MachineImage.latestAmazonLinux2()) .securityGroup(mySecurityGroup) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
MachineImage
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
MachineImage
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionstatic IMachineImage
fromSsmParameter
(String parameterName) An image specified in SSM parameter store.static IMachineImage
fromSsmParameter
(String parameterName, SsmParameterImageOptions options) An image specified in SSM parameter store.static IMachineImage
genericLinux
(Map<String, String> amiMap) A Linux image where you specify the AMI ID for every region.static IMachineImage
genericLinux
(Map<String, String> amiMap, GenericLinuxImageProps props) A Linux image where you specify the AMI ID for every region.static IMachineImage
genericWindows
(Map<String, String> amiMap) A Windows image where you specify the AMI ID for every region.static IMachineImage
genericWindows
(Map<String, String> amiMap, GenericWindowsImageProps props) A Windows image where you specify the AMI ID for every region.static IMachineImage
Deprecated.use MachineImage.latestAmazonLinux2 insteadstatic IMachineImage
Deprecated.use MachineImage.latestAmazonLinux2 insteadstatic IMachineImage
An Amazon Linux 2 image that is automatically kept up-to-date.static IMachineImage
An Amazon Linux 2 image that is automatically kept up-to-date.static IMachineImage
Deprecated.use latestAmazonLinux2023() insteadstatic IMachineImage
Deprecated.use latestAmazonLinux2023() insteadstatic IMachineImage
An Amazon Linux 2023 image that is automatically kept up-to-date.static IMachineImage
An Amazon Linux 2023 image that is automatically kept up-to-date.static IMachineImage
latestWindows
(WindowsVersion version) A Windows image that is automatically kept up-to-date.static IMachineImage
latestWindows
(WindowsVersion version, WindowsImageProps props) A Windows image that is automatically kept up-to-date.static IMachineImage
lookup
(LookupMachineImageProps props) Look up a shared Machine Image using DescribeImages.static IMachineImage
resolveSsmParameterAtLaunch
(String parameterName) An image specified in SSM parameter store that will be resolved at instance launch time.static IMachineImage
resolveSsmParameterAtLaunch
(String parameterName, SsmParameterImageOptions options) An image specified in SSM parameter store that will be resolved at instance launch time.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
MachineImage
protected MachineImage(software.amazon.jsii.JsiiObjectRef objRef) -
MachineImage
protected MachineImage(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
MachineImage
@Stability(Stable) protected MachineImage()
-
-
Method Details
-
fromSsmParameter
@Stability(Stable) @NotNull public static IMachineImage fromSsmParameter(@NotNull String parameterName, @Nullable SsmParameterImageOptions options) 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.- Parameters:
parameterName
- This parameter is required.options
-
-
fromSsmParameter
@Stability(Stable) @NotNull public static IMachineImage fromSsmParameter(@NotNull String parameterName) 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.- Parameters:
parameterName
- This parameter is required.
-
genericLinux
@Stability(Stable) @NotNull public static IMachineImage genericLinux(@NotNull Map<String, String> amiMap, @Nullable GenericLinuxImageProps props) A Linux image where you specify the AMI ID for every region.- Parameters:
amiMap
- For every region where you are deploying the stack, specify the AMI ID for that region. This parameter is required.props
- Customize the image by supplying additional props.
-
genericLinux
@Stability(Stable) @NotNull public static IMachineImage genericLinux(@NotNull Map<String, String> amiMap) A Linux image where you specify the AMI ID for every region.- Parameters:
amiMap
- For every region where you are deploying the stack, specify the AMI ID for that region. This parameter is required.
-
genericWindows
@Stability(Stable) @NotNull public static IMachineImage genericWindows(@NotNull Map<String, String> amiMap, @Nullable GenericWindowsImageProps props) A Windows image where you specify the AMI ID for every region.- Parameters:
amiMap
- For every region where you are deploying the stack, specify the AMI ID for that region. This parameter is required.props
- Customize the image by supplying additional props.
-
genericWindows
@Stability(Stable) @NotNull public static IMachineImage genericWindows(@NotNull Map<String, String> amiMap) A Windows image where you specify the AMI ID for every region.- Parameters:
amiMap
- For every region where you are deploying the stack, specify the AMI ID for that region. This parameter is required.
-
latestAmazonLinux
@Stability(Deprecated) @Deprecated @NotNull public static IMachineImage latestAmazonLinux(@Nullable AmazonLinuxImageProps props) Deprecated.use MachineImage.latestAmazonLinux2 instead(deprecated) 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.
N.B.: "latest" in the name of this function indicates that it always uses the most recent image of a particular generation of Amazon Linux, not that it uses the "latest generation". For backwards compatibility, this function uses Amazon Linux 1 if no generation is specified.
Specify the desired generation using the
generation
property:MachineImage.latestAmazonLinux(AmazonLinuxImageProps.builder() // Use Amazon Linux 2 .generation(AmazonLinuxGeneration.AMAZON_LINUX_2) .build());
- Parameters:
props
-
-
latestAmazonLinux
Deprecated.use MachineImage.latestAmazonLinux2 instead(deprecated) 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.
N.B.: "latest" in the name of this function indicates that it always uses the most recent image of a particular generation of Amazon Linux, not that it uses the "latest generation". For backwards compatibility, this function uses Amazon Linux 1 if no generation is specified.
Specify the desired generation using the
generation
property:MachineImage.latestAmazonLinux(AmazonLinuxImageProps.builder() // Use Amazon Linux 2 .generation(AmazonLinuxGeneration.AMAZON_LINUX_2) .build());
-
latestAmazonLinux2
@Stability(Stable) @NotNull public static IMachineImage latestAmazonLinux2(@Nullable AmazonLinux2ImageSsmParameterProps props) An Amazon Linux 2 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:
props
-
-
latestAmazonLinux2
An Amazon Linux 2 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.
-
latestAmazonLinux2022
@Stability(Deprecated) @Deprecated @NotNull public static IMachineImage latestAmazonLinux2022(@Nullable AmazonLinux2022ImageSsmParameterProps props) Deprecated.- use latestAmazonLinux2023() instead
(deprecated) An Amazon Linux 2022 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:
props
-
-
latestAmazonLinux2022
Deprecated.- use latestAmazonLinux2023() instead
(deprecated) An Amazon Linux 2022 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.
-
latestAmazonLinux2023
@Stability(Stable) @NotNull public static IMachineImage latestAmazonLinux2023(@Nullable AmazonLinux2023ImageSsmParameterProps props) An Amazon Linux 2023 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:
props
-
-
latestAmazonLinux2023
An Amazon Linux 2023 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.
-
latestWindows
@Stability(Stable) @NotNull public static IMachineImage latestWindows(@NotNull WindowsVersion version, @Nullable WindowsImageProps props) 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
- This parameter is required.props
-
-
latestWindows
@Stability(Stable) @NotNull public static IMachineImage latestWindows(@NotNull WindowsVersion version) 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
- This parameter is required.
-
lookup
@Stability(Stable) @NotNull public static IMachineImage lookup(@NotNull LookupMachineImageProps props) 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 thecdk 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.
- Parameters:
props
- This parameter is required.
-
resolveSsmParameterAtLaunch
@Stability(Stable) @NotNull public static IMachineImage resolveSsmParameterAtLaunch(@NotNull String parameterName, @Nullable SsmParameterImageOptions options) An image specified in SSM parameter store that will be resolved at instance launch time.The AMI ID will be resolved at instance launch time.
- Parameters:
parameterName
- The name of SSM parameter containing the AMI ID. This parameter is required.options
- The parameter image options.- See Also:
-
resolveSsmParameterAtLaunch
@Stability(Stable) @NotNull public static IMachineImage resolveSsmParameterAtLaunch(@NotNull String parameterName) An image specified in SSM parameter store that will be resolved at instance launch time.The AMI ID will be resolved at instance launch time.
- Parameters:
parameterName
- The name of SSM parameter containing the AMI ID. This parameter is required.- See Also:
-