Skip to content
v2.278.0

CfnLaunchTemplateProps ​

Struct External

Properties for defining a CfnLaunchTemplate.

Example ​

ts
declare const cluster: eks.Cluster;

const userData = `MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
echo "Running custom user data script"

--==MYBOUNDARY==--\\
`;
const lt = new ec2.CfnLaunchTemplate(this, 'LaunchTemplate', {
  launchTemplateData: {
    instanceType: 't3.small',
    userData: Fn.base64(userData),
  },
});

cluster.addNodegroupCapacity('extra-ng', {
  launchTemplateSpec: {
    id: lt.ref,
    version: lt.attrLatestVersionNumber,
  },
});
python
# cluster: eks.Cluster


user_data = """MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
echo "Running custom user data script"

--==MYBOUNDARY==--\\
"""
lt = ec2.CfnLaunchTemplate(self, "LaunchTemplate",
    launch_template_data=ec2.CfnLaunchTemplate.LaunchTemplateDataProperty(
        instance_type="t3.small",
        user_data=Fn.base64(user_data)
    )
)

cluster.add_nodegroup_capacity("extra-ng",
    launch_template_spec=eks.LaunchTemplateSpec(
        id=lt.ref,
        version=lt.attr_latest_version_number
    )
)
java
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());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Cluster cluster;


var userData = @"MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=""==MYBOUNDARY==""

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset=""us-ascii""

#!/bin/bash
echo ""Running custom user data script""

--==MYBOUNDARY==--\
";
var lt = new CfnLaunchTemplate(this, "LaunchTemplate", new CfnLaunchTemplateProps {
    LaunchTemplateData = new LaunchTemplateDataProperty {
        InstanceType = "t3.small",
        UserData = Fn.Base64(userData)
    }
});

cluster.AddNodegroupCapacity("extra-ng", new NodegroupOptions {
    LaunchTemplateSpec = new LaunchTemplateSpec {
        Id = lt.Ref,
        Version = lt.AttrLatestVersionNumber
    }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var cluster Cluster


userData := `MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="==MYBOUNDARY=="

--==MYBOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
echo "Running custom user data script"

--==MYBOUNDARY==--\\
`
lt := ec2.NewCfnLaunchTemplate(this, jsii.String("LaunchTemplate"), &CfnLaunchTemplateProps{
	LaunchTemplateData: &LaunchTemplateDataProperty{
		InstanceType: jsii.String("t3.small"),
		UserData: awscdk.Fn_Base64(userData),
	},
})

cluster.AddNodegroupCapacity(jsii.String("extra-ng"), &NodegroupOptions{
	LaunchTemplateSpec: &LaunchTemplateSpec{
		Id: lt.ref,
		Version: lt.attrLatestVersionNumber,
	},
})

Properties ​

launchTemplateDataIResolvable | CfnLaunchTemplate.LaunchTemplateDataPropertylaunch_template_datatyping.Union[IResolvable, LaunchTemplateDataProperty]launchTemplateDataIResolvableLaunchTemplateDataIResolvableLaunchTemplateDatainterface{} required #
The information for the launch template.
launchTemplateNameoptionalstringlaunch_template_nameoptionalstrlaunchTemplateNameoptionalStringLaunchTemplateNameoptionalstringLaunchTemplateNameoptional*string #
A name for the launch template.
tagSpecificationsoptionalIResolvable | IResolvable | CfnLaunchTemplate.LaunchTemplateTagSpecificationProperty[]tag_specificationsoptionaltyping.Union[IResolvable, typing.List[typing.Union[IResolvable, LaunchTemplateTagSpecificationProperty]]]tagSpecificationsoptionalIResolvableTagSpecificationsoptionalIResolvableTagSpecificationsoptionalinterface{} #
The tags to apply to the launch template on creation.
notes

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

To specify the tags for resources that are created during instance launch, use TagSpecifications .

versionDescriptionoptionalstringversion_descriptionoptionalstrversionDescriptionoptionalStringVersionDescriptionoptionalstringVersionDescriptionoptional*string #
A description for the first version of the launch template.