Terraform v0.12.29
+ provider.aws v2.70.0
resource "aws_launch_template" "main" {
name = module.tagging.default_resources_tags["Name"]
description = "EKS nodes for ${module.tagging.default_resources_tags["Stage"]}"
instance_type = var.instance_type
update_default_version = true
ebs_optimized = true
block_device_mappings {
device_name = "/dev/sda1"
ebs {
volume_size = 50
delete_on_termination = true
encrypted = true
volume_type = "gp2"
kms_key_id = aws_kms_key.main.arn
}
}
instance_market_options {
market_type = "spot"
spot_options {
block_duration_minutes = "720"
instance_interruption_behavior = "terminate"
max_price = var.spot_price
spot_instance_type = "persistent"
}
}
instance_initiated_shutdown_behavior = "terminate"
hibernation_options {
configured = false
}
placement {
tenancy = "default"
group_name = aws_placement_group.main.id
}
metadata_options {
http_endpoint = "enabled"
http_tokens = "required"
http_put_response_hop_limit = 1
}
monitoring {
enabled = true
}
disable_api_termination = false
tags = module.tagging.default_resources_tags
tag_specifications {
resource_type = "instance"
tags = module.tagging.default_resources_tags
}
tag_specifications {
resource_type = "volume"
tags = module.tagging.default_resources_tags
}
tag_specifications {
resource_type = "spot-instances-request"
tags = module.tagging.default_resources_tags
}
}
~ resource "aws_launch_template" "main" {
arn = "arn:aws:ec2:<REGION>:<ACC_ID>:launch-template/lt-<ID>"
~ default_version = 3 -> (known after apply)
disable_api_termination = false
ebs_optimized = "true"
id = "lt-<ID>"
instance_initiated_shutdown_behavior = "terminate"
instance_type = "c5.2xlarge"
~ latest_version = 3 -> (known after apply)
name = "test-lt-eks"
security_group_names = []
tags = {
"Name" = "test-lt-eks"
}
update_default_version = true
vpc_security_group_ids = []
block_device_mappings {
device_name = "/dev/sda1"
ebs {
delete_on_termination = "true"
encrypted = "true"
iops = 0
kms_key_id = "arn:aws:kms:<REGION>:<ACC_ID>:key/<ID>"
volume_size = 50
volume_type = "gp2"
}
}
hibernation_options {
configured = false
}
instance_market_options {
market_type = "spot"
spot_options {
block_duration_minutes = 720
instance_interruption_behavior = "terminate"
max_price = "0.2"
spot_instance_type = "persistent"
}
}
metadata_options {
http_endpoint = "enabled"
http_put_response_hop_limit = 1
http_tokens = "required"
}
monitoring {
enabled = true
}
placement {
group_name = "test-lt-eks"
partition_number = 0
tenancy = "default"
}
tag_specifications {
resource_type = "instance"
tags = {
"Name" = "test-lt-eks"
}
}
tag_specifications {
resource_type = "volume"
tags = {
"Name" = "test-lt-eks"
}
}
- tag_specifications {
- resource_type = "spot-instances-request" -> null
- tags = {
- "Name" = "test-lt-eks"
} -> null
}
}
Plan: 0 to add, 1 to change, 0 to destroy.
Error: expected tag_specifications.2.resource_type to be one of [instance volume], got spot-instances-request
Set the tags for "spot-instances-request"
Exit with error
terraform planHey, that is not supported by the API itself.
The type of resource to tag. Currently, the resource types that support tagging on creation are instance and volume.
Hey @DrFaust92, yeah I'm not sure what they mean with that, because you can do it via AWS CLI.
aws ec2 create-launch-template-version --launch-template-id <LT_ID> --version-description TestTags --source-version 5 --launch-template-data '{ "TagSpecifications": [ { "ResourceType": "spot-instances-request", "Tags": [ {"Key": "Key-test","Value": "Value-test"}]}]}'
https://docs.aws.amazon.com/cli/latest/reference/ec2/create-launch-template-version.html
This is the output that I got:
{
"LaunchTemplateVersion": {
"LaunchTemplateId": "<LT_ID>",
"LaunchTemplateName": "<LT_NAME>",
"VersionNumber": 6,
"VersionDescription": "TestTags",
"CreateTime": "2020-08-11T15:04:23.000Z",
"CreatedBy": "<USER_ARN>",
"DefaultVersion": false,
"LaunchTemplateData": {
"EbsOptimized": true,
"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1",
"Ebs": {
"Encrypted": true,
"DeleteOnTermination": true,
"KmsKeyId": "<KMS_ARN>",
"VolumeSize": 50,
"VolumeType": "gp2"
}
}
],
"InstanceType": "c5.2xlarge",
"Monitoring": {
"Enabled": true
},
"Placement": {
"GroupName": "<LT_NAME>",
"Tenancy": "default"
},
"InstanceInitiatedShutdownBehavior": "terminate",
"TagSpecifications": [
{
"ResourceType": "spot-instances-request",
"Tags": [
{
"Key": "Key-test",
"Value": "Value-test"
}
]
}
],
"InstanceMarketOptions": {
"MarketType": "spot",
"SpotOptions": {
"MaxPrice": "0.2",
"SpotInstanceType": "persistent",
"BlockDurationMinutes": 720,
"InstanceInterruptionBehavior": "terminate"
}
},
"HibernationOptions": {
"Configured": false
},
"MetadataOptions": {
"HttpTokens": "required",
"HttpPutResponseHopLimit": 1,
"HttpEndpoint": "enabled"
}
}
}
}
Huh, let me check this via the sdk and I'll add the missing options. Docs are out of date apparently.
Thanks for finding this!
Thanks @LozanoMatheus, i opened a PR to add support. i saw in the console that you can add support for these! too bad docs are not updated on this
Support for these additional values in the validation has been merged and will release with version 3.3.0 of the Terraform AWS Provider, later this week. Thanks to @DrFaust92 for the implementation. 👍
This has been released in version 3.3.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!
I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!