Class AmazonLinuxImage

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.GenericSSMParameterImage
software.amazon.awscdk.services.ec2.AmazonLinuxImage
All Implemented Interfaces:
IMachineImage, software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-11-22T02:24:00.128Z") @Stability(Stable) public class AmazonLinuxImage extends GenericSSMParameterImage
Selects the latest version of Amazon Linux.

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.

The AMI ID is selected using the values published to the SSM parameter store.

Example:

 IVpc vpc;
 LoadBalancer lb = LoadBalancer.Builder.create(this, "LB")
         .vpc(vpc)
         .internetFacing(true)
         .build();
 // instance to add as the target for load balancer.
 Instance instance = Instance.Builder.create(this, "targetInstance")
         .vpc(vpc)
         .instanceType(InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO))
         .machineImage(AmazonLinuxImage.Builder.create().generation(AmazonLinuxGeneration.AMAZON_LINUX_2).build())
         .build();
 lb.addTarget(new InstanceTarget(instance));
 
  • Constructor Details

    • AmazonLinuxImage

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

      protected AmazonLinuxImage(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • AmazonLinuxImage

      @Stability(Stable) public AmazonLinuxImage(@Nullable AmazonLinuxImageProps props)
      Parameters:
      props -
    • AmazonLinuxImage

      @Stability(Stable) public AmazonLinuxImage()
  • Method Details

    • ssmParameterName

      @Stability(Stable) @NotNull public static String ssmParameterName(@Nullable AmazonLinuxImageProps props)
      Return the SSM parameter name that will contain the Amazon Linux image with the given attributes.

      Parameters:
      props -
    • ssmParameterName

      @Stability(Stable) @NotNull public static String ssmParameterName()
      Return the SSM parameter name that will contain the Amazon Linux image with the given attributes.
    • getImage

      @Stability(Stable) @NotNull public MachineImageConfig getImage(@NotNull software.constructs.Construct scope)
      Return the image to use in the given context.

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