Class LaunchTemplate
This represents an EC2 LaunchTemplate.
Implements
Inherited Members
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class LaunchTemplate : Resource, ILaunchTemplate, IResource, ILaunchTemplateRef, IConstruct, IDependable, IEnvironmentAware, IGrantable, IConnectable
Syntax (vb)
Public Class LaunchTemplate Inherits Resource Implements ILaunchTemplate, IResource, ILaunchTemplateRef, IConstruct, IDependable, IEnvironmentAware, IGrantable, IConnectable
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
Examples
Vpc vpc;
var sg1 = new SecurityGroup(this, "sg1", new SecurityGroupProps {
Vpc = vpc
});
var sg2 = new SecurityGroup(this, "sg2", new SecurityGroupProps {
Vpc = vpc
});
var launchTemplate = new LaunchTemplate(this, "LaunchTemplate", new LaunchTemplateProps {
MachineImage = MachineImage.LatestAmazonLinux2023(),
SecurityGroup = sg1
});
launchTemplate.AddSecurityGroup(sg2);
Synopsis
Constructors
| LaunchTemplate(Construct, string, ILaunchTemplateProps?) | This represents an EC2 LaunchTemplate. |
Properties
| Connections | Allows specifying security group connections for the instance. |
| DefaultVersionNumber | The default version for the launch template. |
| GrantPrincipal | Principal to grant permissions to. |
| ImageId | The AMI ID of the image to use. |
| InstanceType | Type of instance to launch. |
| LatestVersionNumber | The latest version of the launch template. |
| LaunchTemplateId | The identifier of the Launch Template. |
| LaunchTemplateName | The name of the Launch Template. |
| LaunchTemplateRef | A reference to a LaunchTemplate resource. |
| OsType | The type of OS the instance is running. |
| PROPERTY_INJECTION_ID | Uniquely identifies this class. |
| Role | IAM Role assumed by instances that are launched from this template. |
| Tags | TagManager for tagging support. |
| UserData | UserData executed by instances that are launched from this template. |
| VersionNumber | The version number of this launch template to use. |
Methods
| AddSecurityGroup(ISecurityGroup) | Add the security group to the instance. |
| FromLaunchTemplateAttributes(Construct, string, ILaunchTemplateAttributes) | Import an existing LaunchTemplate. |
Constructors
LaunchTemplate(Construct, string, ILaunchTemplateProps?)
This represents an EC2 LaunchTemplate.
public LaunchTemplate(Construct scope, string id, ILaunchTemplateProps? props = null)
Parameters
- scope Construct
- id string
- props ILaunchTemplateProps
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
Examples
Vpc vpc;
var sg1 = new SecurityGroup(this, "sg1", new SecurityGroupProps {
Vpc = vpc
});
var sg2 = new SecurityGroup(this, "sg2", new SecurityGroupProps {
Vpc = vpc
});
var launchTemplate = new LaunchTemplate(this, "LaunchTemplate", new LaunchTemplateProps {
MachineImage = MachineImage.LatestAmazonLinux2023(),
SecurityGroup = sg1
});
launchTemplate.AddSecurityGroup(sg2);
Properties
Connections
Allows specifying security group connections for the instance.
public virtual Connections_ Connections { get; }
Property Value
Remarks
Note: Only available if you provide a securityGroup when constructing the LaunchTemplate.
DefaultVersionNumber
The default version for the launch template.
public virtual string DefaultVersionNumber { get; }
Property Value
Remarks
Attribute: true
GrantPrincipal
Principal to grant permissions to.
public virtual IPrincipal GrantPrincipal { get; }
Property Value
Remarks
Note: Only available if you provide a role when constructing the LaunchTemplate.
ImageId
The AMI ID of the image to use.
public virtual string? ImageId { get; }
Property Value
Remarks
Attribute: true
InstanceType
Type of instance to launch.
public virtual InstanceType? InstanceType { get; }
Property Value
Remarks
Attribute: true
LatestVersionNumber
The latest version of the launch template.
public virtual string LatestVersionNumber { get; }
Property Value
Remarks
Attribute: true
LaunchTemplateId
The identifier of the Launch Template.
public virtual string? LaunchTemplateId { get; }
Property Value
Remarks
Exactly one of launchTemplateId and launchTemplateName will be set.
LaunchTemplateName
The name of the Launch Template.
public virtual string? LaunchTemplateName { get; }
Property Value
Remarks
Exactly one of launchTemplateId and launchTemplateName will be set.
LaunchTemplateRef
A reference to a LaunchTemplate resource.
public virtual ILaunchTemplateReference LaunchTemplateRef { get; }
Property Value
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
OsType
The type of OS the instance is running.
public virtual OperatingSystemType? OsType { get; }
Property Value
Remarks
Attribute: true
PROPERTY_INJECTION_ID
Uniquely identifies this class.
public static string PROPERTY_INJECTION_ID { get; }
Property Value
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
Role
IAM Role assumed by instances that are launched from this template.
public virtual IRole? Role { get; }
Property Value
Remarks
Attribute: true
Tags
TagManager for tagging support.
protected virtual TagManager Tags { get; }
Property Value
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
UserData
UserData executed by instances that are launched from this template.
public virtual UserData? UserData { get; }
Property Value
Remarks
Attribute: true
VersionNumber
The version number of this launch template to use.
public virtual string VersionNumber { get; }
Property Value
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
Methods
AddSecurityGroup(ISecurityGroup)
Add the security group to the instance.
public virtual void AddSecurityGroup(ISecurityGroup securityGroup)
Parameters
- securityGroup ISecurityGroup
: The security group to add.
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused
FromLaunchTemplateAttributes(Construct, string, ILaunchTemplateAttributes)
Import an existing LaunchTemplate.
public static ILaunchTemplate FromLaunchTemplateAttributes(Construct scope, string id, ILaunchTemplateAttributes attrs)
Parameters
- scope Construct
- id string
- attrs ILaunchTemplateAttributes
Returns
Remarks
See: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html
ExampleMetadata: infused