Class MachineImage

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.MachineImage
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:39.456Z") @Stability(Stable) public abstract class MachineImage extends software.amazon.jsii.JsiiObject
Factory functions for standard Amazon Machine Image objects.

Example:

 Vpc vpc;
 LaunchTemplate template = LaunchTemplate.Builder.create(this, "LaunchTemplate")
         .machineImage(MachineImage.latestAmazonLinux())
         .securityGroup(SecurityGroup.Builder.create(this, "LaunchTemplateSG")
                 .vpc(vpc)
                 .build())
         .build();
 
  • 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.
    • fromSSMParameter

      @Stability(Deprecated) @Deprecated @NotNull public static IMachineImage fromSSMParameter(@NotNull String parameterName, @NotNull OperatingSystemType os, @Nullable UserData userData)
      Deprecated.
      Use MachineImage.fromSsmParameter() instead
      (deprecated) 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:
      parameterName - The name of SSM parameter containing the AMi id. This parameter is required.
      os - The operating system type of the AMI. This parameter is required.
      userData - optional user data for the given image.
    • fromSSMParameter

      @Stability(Deprecated) @Deprecated @NotNull public static IMachineImage fromSSMParameter(@NotNull String parameterName, @NotNull OperatingSystemType os)
      Deprecated.
      Use MachineImage.fromSsmParameter() instead
      (deprecated) 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:
      parameterName - The name of SSM parameter containing the AMi id. This parameter is required.
      os - The operating system type of the AMI. 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(Stable) @NotNull public static IMachineImage latestAmazonLinux(@Nullable AmazonLinuxImageProps props)
      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:
      props -
    • latestAmazonLinux

      @Stability(Stable) @NotNull public static IMachineImage latestAmazonLinux()
      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.

    • 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 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.

      Parameters:
      props - This parameter is required.