Class LaunchTemplate

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.Resource
software.amazon.awscdk.services.ec2.LaunchTemplate
All Implemented Interfaces:
IResource, IConnectable, ILaunchTemplate, IGrantable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.98.0 (build 00b106d)", date="2024-05-08T21:35:06.190Z") @Stability(Stable) public class LaunchTemplate extends Resource implements ILaunchTemplate, IGrantable, IConnectable
This represents an EC2 LaunchTemplate.

Example:

 Vpc vpc;
 SecurityGroup sg1 = SecurityGroup.Builder.create(this, "sg1")
         .vpc(vpc)
         .build();
 SecurityGroup sg2 = SecurityGroup.Builder.create(this, "sg2")
         .vpc(vpc)
         .build();
 LaunchTemplate launchTemplate = LaunchTemplate.Builder.create(this, "LaunchTemplate")
         .machineImage(MachineImage.latestAmazonLinux2023())
         .securityGroup(sg1)
         .build();
 launchTemplate.addSecurityGroup(sg2);
 

See Also:
  • Constructor Details

    • LaunchTemplate

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

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

      @Stability(Stable) public LaunchTemplate(@NotNull software.constructs.Construct scope, @NotNull String id, @Nullable LaunchTemplateProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props -
    • LaunchTemplate

      @Stability(Stable) public LaunchTemplate(@NotNull software.constructs.Construct scope, @NotNull String id)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
  • Method Details

    • fromLaunchTemplateAttributes

      @Stability(Stable) @NotNull public static ILaunchTemplate fromLaunchTemplateAttributes(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull LaunchTemplateAttributes attrs)
      Import an existing LaunchTemplate.

      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      attrs - This parameter is required.
    • addSecurityGroup

      @Stability(Stable) public void addSecurityGroup(@NotNull ISecurityGroup securityGroup)
      Add the security group to the instance.

      Parameters:
      securityGroup - : The security group to add. This parameter is required.
    • getConnections

      @Stability(Stable) @NotNull public Connections getConnections()
      Allows specifying security group connections for the instance.
      Specified by:
      getConnections in interface IConnectable
    • getDefaultVersionNumber

      @Stability(Stable) @NotNull public String getDefaultVersionNumber()
      The default version for the launch template.
    • getGrantPrincipal

      @Stability(Stable) @NotNull public IPrincipal getGrantPrincipal()
      Principal to grant permissions to.
      Specified by:
      getGrantPrincipal in interface IGrantable
    • getLatestVersionNumber

      @Stability(Stable) @NotNull public String getLatestVersionNumber()
      The latest version of the launch template.
    • getTags

      @Stability(Stable) @NotNull protected TagManager getTags()
      TagManager for tagging support.
    • getVersionNumber

      @Stability(Stable) @NotNull public String getVersionNumber()
      The version number of this launch template to use.
      Specified by:
      getVersionNumber in interface ILaunchTemplate
    • getImageId

      @Stability(Stable) @Nullable public String getImageId()
      The AMI ID of the image to use.
    • getInstanceType

      @Stability(Stable) @Nullable public InstanceType getInstanceType()
      Type of instance to launch.
    • getLaunchTemplateId

      @Stability(Stable) @Nullable public String getLaunchTemplateId()
      The identifier of the Launch Template.

      Exactly one of launchTemplateId and launchTemplateName will be set.

      Specified by:
      getLaunchTemplateId in interface ILaunchTemplate
    • getLaunchTemplateName

      @Stability(Stable) @Nullable public String getLaunchTemplateName()
      The name of the Launch Template.

      Exactly one of launchTemplateId and launchTemplateName will be set.

      Specified by:
      getLaunchTemplateName in interface ILaunchTemplate
    • getOsType

      @Stability(Stable) @Nullable public OperatingSystemType getOsType()
      The type of OS the instance is running.
    • getRole

      @Stability(Stable) @Nullable public IRole getRole()
      IAM Role assumed by instances that are launched from this template.
    • getUserData

      @Stability(Stable) @Nullable public UserData getUserData()
      UserData executed by instances that are launched from this template.