Launch Template Args
Provides an EC2 launch template resource. Can be used to create instances or auto scaling groups.
Example Usage
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.LaunchTemplate;
import com.pulumi.aws.ec2.LaunchTemplateArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateBlockDeviceMappingArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateBlockDeviceMappingEbsArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateCapacityReservationSpecificationArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateCpuOptionsArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateCreditSpecificationArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateElasticGpuSpecificationArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateElasticInferenceAcceleratorArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateIamInstanceProfileArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateInstanceMarketOptionsArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateLicenseSpecificationArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateMetadataOptionsArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateMonitoringArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateNetworkInterfaceArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplatePlacementArgs;
import com.pulumi.aws.ec2.inputs.LaunchTemplateTagSpecificationArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var foo = new LaunchTemplate("foo", LaunchTemplateArgs.builder()
.blockDeviceMappings(LaunchTemplateBlockDeviceMappingArgs.builder()
.deviceName("/dev/sdf")
.ebs(LaunchTemplateBlockDeviceMappingEbsArgs.builder()
.volumeSize(20)
.build())
.build())
.capacityReservationSpecification(LaunchTemplateCapacityReservationSpecificationArgs.builder()
.capacityReservationPreference("open")
.build())
.cpuOptions(LaunchTemplateCpuOptionsArgs.builder()
.coreCount(4)
.threadsPerCore(2)
.build())
.creditSpecification(LaunchTemplateCreditSpecificationArgs.builder()
.cpuCredits("standard")
.build())
.disableApiStop(true)
.disableApiTermination(true)
.ebsOptimized(true)
.elasticGpuSpecifications(LaunchTemplateElasticGpuSpecificationArgs.builder()
.type("test")
.build())
.elasticInferenceAccelerator(LaunchTemplateElasticInferenceAcceleratorArgs.builder()
.type("eia1.medium")
.build())
.iamInstanceProfile(LaunchTemplateIamInstanceProfileArgs.builder()
.name("test")
.build())
.imageId("ami-test")
.instanceInitiatedShutdownBehavior("terminate")
.instanceMarketOptions(LaunchTemplateInstanceMarketOptionsArgs.builder()
.marketType("spot")
.build())
.instanceType("t2.micro")
.kernelId("test")
.keyName("test")
.licenseSpecifications(LaunchTemplateLicenseSpecificationArgs.builder()
.licenseConfigurationArn("arn:aws:license-manager:eu-west-1:123456789012:license-configuration:lic-0123456789abcdef0123456789abcdef")
.build())
.metadataOptions(LaunchTemplateMetadataOptionsArgs.builder()
.httpEndpoint("enabled")
.httpTokens("required")
.httpPutResponseHopLimit(1)
.instanceMetadataTags("enabled")
.build())
.monitoring(LaunchTemplateMonitoringArgs.builder()
.enabled(true)
.build())
.networkInterfaces(LaunchTemplateNetworkInterfaceArgs.builder()
.associatePublicIpAddress(true)
.build())
.placement(LaunchTemplatePlacementArgs.builder()
.availabilityZone("us-west-2a")
.build())
.ramDiskId("test")
.vpcSecurityGroupIds("sg-12345678")
.tagSpecifications(LaunchTemplateTagSpecificationArgs.builder()
.resourceType("instance")
.tags(Map.of("Name", "test"))
.build())
.userData(Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(String.format("%s/example.sh", path.module())))))
.build());
}
}
Import
Launch Templates can be imported using the id
, e.g.,
$ pulumi import aws:ec2/launchTemplate:LaunchTemplate web lt-12345678
Constructors
Properties
Specify volumes to attach to the instance besides the volumes specified by the AMI. See Block Devices below for details.
Targeting for EC2 capacity reservations. See Capacity Reservation Specification below for more details.
The CPU options for the instance. See CPU Options below for more details.
Customize the credit specification of the instance. See Credit Specification below for more details.
Default Version of the launch template.
Description of the launch template.
If true, enables EC2 Instance Stop Protection.
If true
, enables [EC2 Instance
If true
, the launched EC2 instance will be EBS-optimized.
The elastic GPU to attach to the instance. See Elastic GPU below for more details.
Configuration block containing an Elastic Inference Accelerator to attach to the instance. See Elastic Inference Accelerator below for more details.
Enable Nitro Enclaves on launched instances. See Enclave Options below for more details.
The hibernation options for the instance. See Hibernation Options below for more details.
The IAM Instance Profile to launch the instance with. See Instance Profile below for more details.
Shutdown behavior for the instance. Can be stop
or terminate
. (Default: stop
).
The market (purchasing) option for the instance. See Market Options below for details.
The attribute requirements for the type of instance. If present then instance_type
cannot be present.
The type of the instance. If present then instance_requirements
cannot be present.
A list of license specifications to associate with. See License Specification below for more details.
The maintenance options for the instance. See Maintenance Options below for more details.
Customize the metadata options for the instance. See Metadata Options below for more details.
The monitoring option for the instance. See Monitoring below for more details.
Creates a unique name beginning with the specified prefix. Conflicts with name
.
Customize network interfaces to be attached at instance boot time. See Network Interfaces below for more details.
The placement of the instance. See Placement below for more details.
The options for the instance hostname. The default values are inherited from the subnet. See Private DNS Name Options below for more details.
A list of security group names to associate with. If you are creating Instances in a VPC, use vpc_security_group_ids
instead.
The tags to apply to the resources during launch. See Tag Specifications below for more details.
Whether to update Default Version each update. Conflicts with default_version
.
A list of security group IDs to associate with. Conflicts with network_interfaces.security_groups