Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws_launch_template don't support tags for "spot-instances-request" and "elastic-gpu" #14558

Closed
LozanoMatheus opened this issue Aug 11, 2020 · 7 comments · Fixed by #14662
Closed
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Milestone

Comments

@LozanoMatheus
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform AWS Provider Version

Terraform v0.12.29
+ provider.aws v2.70.0

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

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
  }
}

Debug Output

  ~ 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.

Panic Output

Error: expected tag_specifications.2.resource_type to be one of [instance volume], got spot-instances-request

Expected Behavior

Set the tags for "spot-instances-request"

Actual Behavior

Exit with error

Steps to Reproduce

  1. terraform plan

Important Factoids

References

@ghost ghost added the service/ec2 Issues and PRs that pertain to the ec2 service. label Aug 11, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Aug 11, 2020
@DrFaust92
Copy link
Collaborator

Hey, 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.

@LozanoMatheus
Copy link
Author

LozanoMatheus commented Aug 11, 2020

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"
            }
        }
    }
}

@DrFaust92
Copy link
Collaborator

DrFaust92 commented Aug 11, 2020

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!

@DrFaust92 DrFaust92 added enhancement Requests to existing resources that expand the functionality or scope. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 14, 2020
@DrFaust92
Copy link
Collaborator

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

@bflad bflad added this to the v3.3.0 milestone Aug 18, 2020
@bflad
Copy link
Contributor

bflad commented Aug 18, 2020

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. 👍

@ghost
Copy link

ghost commented Aug 20, 2020

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!

@ghost
Copy link

ghost commented Sep 17, 2020

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!

@ghost ghost locked and limited conversation to collaborators Sep 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
3 participants