Class CfnLaunchTemplate

java.lang.Object
software.amazon.jsii.JsiiObject
All Implemented Interfaces:
IConstruct, IDependable, IInspectable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:30:38.679Z") @Stability(Stable) public class CfnLaunchTemplate extends CfnResource implements IInspectable
A CloudFormation AWS::EC2::LaunchTemplate.

Specifies the properties for creating a launch template.

The minimum required properties for specifying a launch template are as follows:

  • You must specify at least one property for the launch template data.
  • You do not need to specify a name for the launch template. If you do not specify a name, AWS CloudFormation creates the name for you.

A launch template can contain some or all of the configuration information to launch an instance. When you launch an instance using a launch template, instance properties that are not specified in the launch template use default values, except the ImageId property, which has no default value. If you do not specify an AMI ID for the launch template ImageId property, you must specify an AMI ID for the instance ImageId property.

For more information, see Launch an instance from a launch template in the Amazon EC2 User Guide .

Example:

 Cluster cluster;
 String userData = "MIME-Version: 1.0\nContent-Type: multipart/mixed; boundary=\"==MYBOUNDARY==\"\n\n--==MYBOUNDARY==\nContent-Type: text/x-shellscript; charset=\"us-ascii\"\n\n#!/bin/bash\necho \"Running custom user data script\"\n\n--==MYBOUNDARY==--\\\n";
 CfnLaunchTemplate lt = CfnLaunchTemplate.Builder.create(this, "LaunchTemplate")
         .launchTemplateData(LaunchTemplateDataProperty.builder()
                 .instanceType("t3.small")
                 .userData(Fn.base64(userData))
                 .build())
         .build();
 cluster.addNodegroupCapacity("extra-ng", NodegroupOptions.builder()
         .launchTemplateSpec(LaunchTemplateSpec.builder()
                 .id(lt.getRef())
                 .version(lt.getAttrLatestVersionNumber())
                 .build())
         .build());
 
  • Field Details

    • CFN_RESOURCE_TYPE_NAME

      @Stability(Stable) public static final String CFN_RESOURCE_TYPE_NAME
      The CloudFormation resource type name for this resource class.
  • Constructor Details

    • CfnLaunchTemplate

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

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

      @Stability(Stable) public CfnLaunchTemplate(@NotNull Construct scope, @NotNull String id, @NotNull CfnLaunchTemplateProps props)
      Create a new AWS::EC2::LaunchTemplate.

      Parameters:
      scope -
      • scope in which this resource is defined.
      This parameter is required.
      id -
      • scoped id of the resource.
      This parameter is required.
      props -
      • resource properties.
      This parameter is required.
  • Method Details

    • inspect

      @Stability(Stable) public void inspect(@NotNull TreeInspector inspector)
      Examines the CloudFormation resource and discloses attributes.

      Specified by:
      inspect in interface IInspectable
      Parameters:
      inspector -
      • tree inspector to collect and process attributes.
      This parameter is required.
    • renderProperties

      @Stability(Stable) @NotNull protected Map<String,Object> renderProperties(@NotNull Map<String,Object> props)
      Overrides:
      renderProperties in class CfnResource
      Parameters:
      props - This parameter is required.
    • getAttrDefaultVersionNumber

      @Stability(Stable) @NotNull public String getAttrDefaultVersionNumber()
      The default version of the launch template, such as 2.

      The default version of a launch template cannot be specified in AWS CloudFormation . The default version can be set in the Amazon EC2 console or by using the modify-launch-template AWS CLI command.

    • getAttrLatestVersionNumber

      @Stability(Stable) @NotNull public String getAttrLatestVersionNumber()
      The latest version of the launch template, such as 5 .
    • getCfnProperties

      @Stability(Stable) @NotNull protected Map<String,Object> getCfnProperties()
      Overrides:
      getCfnProperties in class CfnResource
    • getLaunchTemplateData

      @Stability(Stable) @NotNull public Object getLaunchTemplateData()
      The information for the launch template.
    • setLaunchTemplateData

      @Stability(Stable) public void setLaunchTemplateData(@NotNull IResolvable value)
      The information for the launch template.
    • setLaunchTemplateData

      @Stability(Stable) public void setLaunchTemplateData(@NotNull CfnLaunchTemplate.LaunchTemplateDataProperty value)
      The information for the launch template.
    • getLaunchTemplateName

      @Stability(Stable) @Nullable public String getLaunchTemplateName()
      A name for the launch template.
    • setLaunchTemplateName

      @Stability(Stable) public void setLaunchTemplateName(@Nullable String value)
      A name for the launch template.
    • getTagSpecifications

      @Stability(Stable) @Nullable public Object getTagSpecifications()
      The tags to apply to the launch template on creation.

      To tag the launch template, the resource type must be launch-template .

      To specify the tags for the resources that are created when an instance is launched, you must use the TagSpecifications parameter in the launch template data structure.

    • setTagSpecifications

      @Stability(Stable) public void setTagSpecifications(@Nullable IResolvable value)
      The tags to apply to the launch template on creation.

      To tag the launch template, the resource type must be launch-template .

      To specify the tags for the resources that are created when an instance is launched, you must use the TagSpecifications parameter in the launch template data structure.

    • setTagSpecifications

      @Stability(Stable) public void setTagSpecifications(@Nullable List<Object> value)
      The tags to apply to the launch template on creation.

      To tag the launch template, the resource type must be launch-template .

      To specify the tags for the resources that are created when an instance is launched, you must use the TagSpecifications parameter in the launch template data structure.

    • getVersionDescription

      @Stability(Stable) @Nullable public String getVersionDescription()
      A description for the first version of the launch template.
    • setVersionDescription

      @Stability(Stable) public void setVersionDescription(@Nullable String value)
      A description for the first version of the launch template.