Class EcsOptimizedImage

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ecs.EcsOptimizedImage
All Implemented Interfaces:
IMachineImage, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-27T16:50:57.007Z") @Stability(Stable) public class EcsOptimizedImage extends software.amazon.jsii.JsiiObject implements IMachineImage
Construct a Linux or Windows machine image from the latest ECS Optimized AMI published in SSM.

Example:

 Vpc vpc;
 Cluster cluster = Cluster.Builder.create(this, "Cluster")
         .vpc(vpc)
         .build();
 // Either add default capacity
 cluster.addCapacity("DefaultAutoScalingGroupCapacity", AddCapacityOptions.builder()
         .instanceType(new InstanceType("t2.xlarge"))
         .desiredCapacity(3)
         .build());
 // Or add customized capacity. Be sure to start the Amazon ECS-optimized AMI.
 AutoScalingGroup autoScalingGroup = AutoScalingGroup.Builder.create(this, "ASG")
         .vpc(vpc)
         .instanceType(new InstanceType("t2.xlarge"))
         .machineImage(EcsOptimizedImage.amazonLinux())
         // Or use Amazon ECS-Optimized Amazon Linux 2 AMI
         // machineImage: EcsOptimizedImage.amazonLinux2(),
         .desiredCapacity(3)
         .build();
 AsgCapacityProvider capacityProvider = AsgCapacityProvider.Builder.create(this, "AsgCapacityProvider")
         .autoScalingGroup(autoScalingGroup)
         .build();
 cluster.addAsgCapacityProvider(capacityProvider);
 
  • Constructor Details

    • EcsOptimizedImage

      protected EcsOptimizedImage(software.amazon.jsii.JsiiObjectRef objRef)
    • EcsOptimizedImage

      protected EcsOptimizedImage(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
  • Method Details

    • amazonLinux

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux(@Nullable EcsOptimizedImageOptions options)
      Construct an Amazon Linux AMI image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      options -
    • amazonLinux

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux()
      Construct an Amazon Linux AMI image from the latest ECS Optimized AMI published in SSM.
    • amazonLinux2

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux2(@Nullable AmiHardwareType hardwareType, @Nullable EcsOptimizedImageOptions options)
      Construct an Amazon Linux 2 image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      hardwareType - ECS-optimized AMI variant to use.
      options -
    • amazonLinux2

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux2(@Nullable AmiHardwareType hardwareType)
      Construct an Amazon Linux 2 image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      hardwareType - ECS-optimized AMI variant to use.
    • amazonLinux2

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux2()
      Construct an Amazon Linux 2 image from the latest ECS Optimized AMI published in SSM.
    • amazonLinux2023

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux2023(@Nullable AmiHardwareType hardwareType, @Nullable EcsOptimizedImageOptions options)
      Construct an Amazon Linux 2023 image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      hardwareType - ECS-optimized AMI variant to use.
      options -
    • amazonLinux2023

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux2023(@Nullable AmiHardwareType hardwareType)
      Construct an Amazon Linux 2023 image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      hardwareType - ECS-optimized AMI variant to use.
    • amazonLinux2023

      @Stability(Stable) @NotNull public static EcsOptimizedImage amazonLinux2023()
      Construct an Amazon Linux 2023 image from the latest ECS Optimized AMI published in SSM.
    • windows

      @Stability(Stable) @NotNull public static EcsOptimizedImage windows(@NotNull WindowsOptimizedVersion windowsVersion, @Nullable EcsOptimizedImageOptions options)
      Construct a Windows image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      windowsVersion - Windows Version to use. This parameter is required.
      options -
    • windows

      @Stability(Stable) @NotNull public static EcsOptimizedImage windows(@NotNull WindowsOptimizedVersion windowsVersion)
      Construct a Windows image from the latest ECS Optimized AMI published in SSM.

      Parameters:
      windowsVersion - Windows Version to use. This parameter is required.
    • getImage

      @Stability(Stable) @NotNull public MachineImageConfig getImage(@NotNull software.constructs.Construct scope)
      Return the correct image.

      Specified by:
      getImage in interface IMachineImage
      Parameters:
      scope - This parameter is required.