launch_templates
Creates, updates, deletes or gets a launch_template resource or lists launch_templates in a region
Overview
| Name | launch_templates |
| Type | Resource |
| Description | 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 can optionally specify a name for the launch template. If you do not specify a name, CFN creates a 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](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-launch-templates.html) in the *Amazon EC2 User Guide*. |
| Id | awscc.ec2.launch_templates |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
launch_template_name | string | A name for the launch template. |
launch_template_data | object | The information for the launch template. |
version_description | string | A description for the first version of the launch template. |
tag_specifications | array | The tags to apply to the launch template on creation. To tag the launch template, the resource type must be ``launch-template``.<br />To specify the tags for resources that are created during instance launch, use [TagSpecifications](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-launchtemplate-launchtemplatedata.html#cfn-ec2-launchtemplate-launchtemplatedata-tagspecifications). |
latest_version_number | string | |
launch_template_id | string | |
default_version_number | string | |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
launch_template_id | string | |
region | string | AWS region. |
For more information, see AWS::EC2::LaunchTemplate.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | launch_templates | INSERT | LaunchTemplateData, region |
delete_resource | launch_templates | DELETE | Identifier, region |
update_resource | launch_templates | UPDATE | Identifier, PatchDocument, region |
list_resources | launch_templates_list_only | SELECT | region |
get_resource | launch_templates | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual launch_template.
SELECT
region,
launch_template_name,
launch_template_data,
version_description,
tag_specifications,
latest_version_number,
launch_template_id,
default_version_number
FROM awscc.ec2.launch_templates
WHERE
region = 'us-east-1' AND
Identifier = '{{ launch_template_id }}';
Lists all launch_templates in a region.
SELECT
region,
launch_template_id
FROM awscc.ec2.launch_templates_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new launch_template resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.ec2.launch_templates (
LaunchTemplateData,
region
)
SELECT
'{{ launch_template_data }}',
'{{ region }}';
/*+ create */
INSERT INTO awscc.ec2.launch_templates (
LaunchTemplateName,
LaunchTemplateData,
VersionDescription,
TagSpecifications,
region
)
SELECT
'{{ launch_template_name }}',
'{{ launch_template_data }}',
'{{ version_description }}',
'{{ tag_specifications }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: launch_template
props:
- name: launch_template_name
value: '{{ launch_template_name }}'
- name: launch_template_data
value:
security_groups:
- '{{ security_groups[0] }}'
tag_specifications:
- resource_type: '{{ resource_type }}'
tags:
- key: '{{ key }}'
value: '{{ value }}'
network_performance_options:
bandwidth_weighting: '{{ bandwidth_weighting }}'
user_data: '{{ user_data }}'
block_device_mappings:
- device_name: '{{ device_name }}'
ebs:
delete_on_termination: '{{ delete_on_termination }}'
encrypted: '{{ encrypted }}'
iops: '{{ iops }}'
snapshot_id: '{{ snapshot_id }}'
volume_size: '{{ volume_size }}'
volume_type: '{{ volume_type }}'
no_device: '{{ no_device }}'
virtual_name: '{{ virtual_name }}'
maintenance_options:
auto_recovery: '{{ auto_recovery }}'
iam_instance_profile:
arn: '{{ arn }}'
name: '{{ name }}'
kernel_id: '{{ kernel_id }}'
ebs_optimized: '{{ ebs_optimized }}'
placement:
group_name: '{{ group_name }}'
tenancy: '{{ tenancy }}'
spread_domain: '{{ spread_domain }}'
partition_number: '{{ partition_number }}'
availability_zone: '{{ availability_zone }}'
affinity: '{{ affinity }}'
host_id: '{{ host_id }}'
host_resource_group_arn: '{{ host_resource_group_arn }}'
group_id: '{{ group_id }}'
network_interfaces:
- description: '{{ description }}'
private_ip_address: '{{ private_ip_address }}'
private_ip_addresses:
- primary: '{{ primary }}'
private_ip_address: '{{ private_ip_address }}'
secondary_private_ip_address_count: '{{ secondary_private_ip_address_count }}'
ipv6_prefix_count: '{{ ipv6_prefix_count }}'
ipv4_prefixes:
- ipv4_prefix: '{{ ipv4_prefix }}'
ipv4_prefix_count: '{{ ipv4_prefix_count }}'
enable_primary_ipv6: '{{ enable_primary_ipv6 }}'
group_set:
- '{{ group_set[0] }}'
ipv6_addresses:
- ipv6_address: '{{ ipv6_address }}'
ipv6_prefixes:
- ipv6_prefix: '{{ ipv6_prefix }}'
subnet_id: '{{ subnet_id }}'
source_dest_check: '{{ source_dest_check }}'
interface_type: '{{ interface_type }}'
ipv6_address_count: '{{ ipv6_address_count }}'
tags:
- null
connection_tracking_specification:
udp_timeout: '{{ udp_timeout }}'
tcp_established_timeout: '{{ tcp_established_timeout }}'
udp_stream_timeout: '{{ udp_stream_timeout }}'
enclave_options:
enabled: '{{ enabled }}'
image_id: '{{ image_id }}'
instance_type: '{{ instance_type }}'
monitoring:
enabled: '{{ enabled }}'
hibernation_options:
configured: '{{ configured }}'
metadata_options:
http_put_response_hop_limit: '{{ http_put_response_hop_limit }}'
http_tokens: '{{ http_tokens }}'
http_protocol_ipv6: '{{ http_protocol_ipv6 }}'
instance_metadata_tags: '{{ instance_metadata_tags }}'
http_endpoint: '{{ http_endpoint }}'
license_specifications:
- license_configuration_arn: '{{ license_configuration_arn }}'
instance_initiated_shutdown_behavior: '{{ instance_initiated_shutdown_behavior }}'
disable_api_stop: '{{ disable_api_stop }}'
cpu_options:
threads_per_core: '{{ threads_per_core }}'
amd_sev_snp: '{{ amd_sev_snp }}'
core_count: '{{ core_count }}'
private_dns_name_options:
enable_resource_name_dns_arecord: '{{ enable_resource_name_dns_arecord }}'
hostname_type: '{{ hostname_type }}'
enable_resource_name_dns_aa_aa_record: '{{ enable_resource_name_dns_aa_aa_record }}'
security_group_ids:
- '{{ security_group_ids[0] }}'
key_name: '{{ key_name }}'
disable_api_termination: '{{ disable_api_termination }}'
instance_market_options:
spot_options:
spot_instance_type: '{{ spot_instance_type }}'
instance_interruption_behavior: '{{ instance_interruption_behavior }}'
max_price: '{{ max_price }}'
block_duration_minutes: '{{ block_duration_minutes }}'
valid_until: '{{ valid_until }}'
market_type: '{{ market_type }}'
instance_requirements:
instance_generations:
- '{{ instance_generations[0] }}'
memory_gi_bper_vcpu:
min: null
max: null
accelerator_types:
- '{{ accelerator_types[0] }}'
v_cpu_count:
min: '{{ min }}'
max: '{{ max }}'
accelerator_manufacturers:
- '{{ accelerator_manufacturers[0] }}'
local_storage: '{{ local_storage }}'
cpu_manufacturers:
- '{{ cpu_manufacturers[0] }}'
bare_metal: '{{ bare_metal }}'
require_hibernate_support: '{{ require_hibernate_support }}'
max_spot_price_as_percentage_of_optimal_on_demand_price: '{{ max_spot_price_as_percentage_of_optimal_on_demand_price }}'
on_demand_max_price_percentage_over_lowest_price: '{{ on_demand_max_price_percentage_over_lowest_price }}'
memory_mi_b:
min: '{{ min }}'
max: '{{ max }}'
local_storage_types:
- '{{ local_storage_types[0] }}'
network_interface_count:
min: '{{ min }}'
max: '{{ max }}'
excluded_instance_types:
- '{{ excluded_instance_types[0] }}'
allowed_instance_types:
- '{{ allowed_instance_types[0] }}'
accelerator_count:
min: '{{ min }}'
max: '{{ max }}'
network_bandwidth_gbps:
min: null
max: null
baseline_performance_factors:
cpu:
references:
- instance_family: '{{ instance_family }}'
spot_max_price_percentage_over_lowest_price: '{{ spot_max_price_percentage_over_lowest_price }}'
baseline_ebs_bandwidth_mbps:
min: '{{ min }}'
max: '{{ max }}'
accelerator_names:
- '{{ accelerator_names[0] }}'
accelerator_total_memory_mi_b:
min: '{{ min }}'
max: '{{ max }}'
burstable_performance: '{{ burstable_performance }}'
total_local_storage_gb:
min: null
max: null
ram_disk_id: '{{ ram_disk_id }}'
capacity_reservation_specification:
capacity_reservation_preference: '{{ capacity_reservation_preference }}'
capacity_reservation_target:
capacity_reservation_resource_group_arn: '{{ capacity_reservation_resource_group_arn }}'
capacity_reservation_id: '{{ capacity_reservation_id }}'
credit_specification:
cpu_credits: '{{ cpu_credits }}'
- name: version_description
value: '{{ version_description }}'
- name: tag_specifications
value:
- resource_type: '{{ resource_type }}'
tags:
- null
UPDATE example
Use the following StackQL query and manifest file to update a launch_template resource, using stack-deploy.
/*+ update */
UPDATE awscc.ec2.launch_templates
SET PatchDocument = string('{{ {
"LaunchTemplateData": launch_template_data,
"VersionDescription": version_description,
"TagSpecifications": tag_specifications
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ launch_template_id }}';
DELETE example
/*+ delete */
DELETE FROM awscc.ec2.launch_templates
WHERE
Identifier = '{{ launch_template_id }}' AND
region = 'us-east-1';
Permissions
To operate on the launch_templates resource, the following permissions are required:
- Read
- Create
- Update
- List
- Delete
ec2:DescribeLaunchTemplates
ec2:CreateLaunchTemplate,
ec2:CreateTags
ec2:CreateLaunchTemplateVersion
ec2:DescribeLaunchTemplates
ec2:DeleteLaunchTemplate,
ec2:DeleteTags,
ec2:DescribeLaunchTemplates