-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch-template.tf
190 lines (160 loc) · 6.89 KB
/
launch-template.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
resource "aws_launch_template" "launch_template" {
name = var.name
name_prefix = var.name_prefix
description = var.description
dynamic "block_device_mappings" {
for_each = var.block_device_mappings
content {
device_name = lookup(block_device_mappings.value, "device_name", null)
no_device = lookup(block_device_mappings.value, "no_device", null)
virtual_name = lookup(block_device_mappings.value, "virtual_name", null)
dynamic "ebs" {
for_each = lookup(block_device_mappings.value, "ebs", []) == [] ? [] : [lookup(block_device_mappings.value, "ebs", [])]
content {
delete_on_termination = lookup(ebs.value, "delete_on_termination", null)
encrypted = lookup(ebs.value, "encrypted", null)
iops = lookup(ebs.value, "iops", null)
kms_key_id = lookup(ebs.value, "kms_key_id", null)
snapshot_id = lookup(ebs.value, "snapshot_id", null)
volume_size = lookup(ebs.value, "volume_size", null)
volume_type = lookup(ebs.value, "volume_type", null)
}
}
}
}
dynamic "capacity_reservation_specification" {
for_each = var.capacity_reservation_specification
content {
capacity_reservation_preference = lookup(capacity_reservation_specification.value, "capacity_reservation_preference", null)
dynamic "capacity_reservation_target" {
for_each = lookup(capacity_reservation_specification.value, "capacity_reservation_target", []) == [] ? [] : [lookup(capacity_reservation_specification.value, "capacity_reservation_target", [])]
content {
capacity_reservation_id = lookup(capacity_reservation_target.value, "capacity_reservation_id", null)
}
}
}
}
dynamic "cpu_options" {
for_each = var.cpu_options
content {
core_count = lookup(cpu_options.value, "core_count", null)
threads_per_core = lookup(cpu_options.value, "threads_per_core", null)
}
}
dynamic "credit_specification" {
for_each = var.credit_specification
content {
cpu_credits = lookup(credit_specification.value, "cpu_credits", null)
}
}
disable_api_termination = var.disable_api_termination
ebs_optimized = var.ebs_optimized
dynamic "elastic_gpu_specifications" {
for_each = var.elastic_gpu_specifications
content {
type = elastic_gpu_specifications.value.type
}
}
dynamic "elastic_inference_accelerator" {
for_each = var.elastic_inference_accelerator
content {
type = elastic_inference_accelerator.value.type
}
}
dynamic "iam_instance_profile" {
for_each = var.iam_instance_profile == {} ? [] : [var.iam_instance_profile]
content {
arn = lookup(iam_instance_profile.value, "arn", null)
name = lookup(iam_instance_profile.value, "name", null)
}
}
image_id = var.image_id
instance_initiated_shutdown_behavior = var.instance_initiated_shutdown_behavior
dynamic "instance_market_options" {
for_each = var.instance_market_options
content {
market_type = lookup(instance_market_options.value, "market_type", null)
dynamic "spot_options" {
for_each = lookup(instance_market_options.value, "spot_options", []) == [] ? [] : [lookup(instance_market_options.value, "spot_options", [])]
content {
block_duration_minutes = lookup(spot_options.value, "block_duration_minutes", null)
instance_interruption_behavior = lookup(spot_options.value, "instance_interruption_behavior", null)
max_price = lookup(spot_options.value, "max_price", null)
spot_instance_type = lookup(spot_options.value, "spot_instance_type", null)
valid_until = lookup(spot_options.value, "valid_until", null)
}
}
}
}
instance_type = var.instance_type
kernel_id = var.kernel_id
key_name = var.key_name
dynamic "license_specification" {
for_each = var.license_specification
content {
license_configuration_arn = license_specification.value.license_configuration_arn
}
}
dynamic "metadata_options" {
for_each = var.metadata_options
content {
http_endpoint = lookup(metadata_options.value, "http_endpoint", null)
http_put_response_hop_limit = lookup(metadata_options.value, "http_put_response_hop_limit", null)
http_tokens = lookup(metadata_options.value, "http_tokens", null)
}
}
dynamic "monitoring" {
for_each = var.monitoring
content {
enabled = lookup(monitoring.value, "enabled", null)
}
}
dynamic "network_interfaces" {
for_each = var.network_interfaces
content {
associate_public_ip_address = lookup(network_interfaces.value, "associate_public_ip_address", null)
delete_on_termination = lookup(network_interfaces.value, "delete_on_termination", null)
description = lookup(network_interfaces.value, "description", null)
device_index = lookup(network_interfaces.value, "device_index", null)
ipv4_address_count = lookup(network_interfaces.value, "ipv4_address_count", null)
ipv4_addresses = lookup(network_interfaces.value, "ipv4_addresses", null)
ipv6_address_count = lookup(network_interfaces.value, "ipv6_address_count", null)
ipv6_addresses = lookup(network_interfaces.value, "ipv6_addresses", null)
network_interface_id = lookup(network_interfaces.value, "network_interface_id", null)
private_ip_address = lookup(network_interfaces.value, "private_ip_address", null)
security_groups = lookup(network_interfaces.value, "security_groups", null)
subnet_id = lookup(network_interfaces.value, "subnet_id", null)
}
}
dynamic "placement" {
for_each = var.placement
content {
affinity = lookup(placement.value, "affinity", null)
availability_zone = lookup(placement.value, "availability_zone", null)
group_name = lookup(placement.value, "group_name", null)
host_id = lookup(placement.value, "host_id", null)
spread_domain = lookup(placement.value, "spread_domain", null)
tenancy = lookup(placement.value, "tenancy", null)
}
}
ram_disk_id = var.ram_disk_id
vpc_security_group_ids = var.vpc_security_group_ids
dynamic "tag_specifications" {
for_each = var.tag_specifications
content {
resource_type = lookup(tag_specifications.value, "resource_type", null)
tags = lookup(tag_specifications.value, "tags", null)
}
}
tags = var.tags
user_data = var.user_data
dynamic "hibernation_options" {
for_each = var.hibernation_options
content {
configured = hibernation_options.value.configured
}
}
lifecycle {
create_before_destroy = true
}
}