From fb9bec2ff5c9cc3ba51642b560f6e1a4a7ce694c Mon Sep 17 00:00:00 2001 From: Ilia Lazebnik Date: Tue, 18 Aug 2020 17:18:01 +0300 Subject: [PATCH] resource/aws_launch_template: add support for "spot-instances-request" and "elastic-gpu" tag spec (#14662) * add support for more tagging types * Update website/docs/r/launch_template.html.markdown Co-authored-by: Kit Ewbank Co-authored-by: Kit Ewbank --- aws/resource_aws_launch_template.go | 2 ++ aws/resource_aws_launch_template_test.go | 26 +++++++++++++++++++- website/docs/r/launch_template.html.markdown | 4 +-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/aws/resource_aws_launch_template.go b/aws/resource_aws_launch_template.go index 869e7356a60..b47b9b74c99 100644 --- a/aws/resource_aws_launch_template.go +++ b/aws/resource_aws_launch_template.go @@ -567,6 +567,8 @@ func resourceAwsLaunchTemplate() *schema.Resource { ValidateFunc: validation.StringInSlice([]string{ ec2.ResourceTypeInstance, ec2.ResourceTypeVolume, + ec2.ResourceTypeSpotInstancesRequest, + ec2.ResourceTypeElasticGpu, }, false), }, "tags": tagsSchema(), diff --git a/aws/resource_aws_launch_template_test.go b/aws/resource_aws_launch_template_test.go index 820f5da4b40..a4aec5f3e04 100644 --- a/aws/resource_aws_launch_template_test.go +++ b/aws/resource_aws_launch_template_test.go @@ -372,7 +372,7 @@ func TestAccAWSLaunchTemplate_data(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "placement.#", "1"), resource.TestCheckResourceAttrSet(resourceName, "ram_disk_id"), resource.TestCheckResourceAttr(resourceName, "vpc_security_group_ids.#", "1"), - resource.TestCheckResourceAttr(resourceName, "tag_specifications.#", "1"), + resource.TestCheckResourceAttr(resourceName, "tag_specifications.#", "4"), ), }, { @@ -1404,6 +1404,30 @@ resource "aws_launch_template" "test" { Name = "test" } } + + tag_specifications { + resource_type = "volume" + + tags = { + Name = "test" + } + } + + tag_specifications { + resource_type = "spot-instances-request" + + tags = { + Name = "test" + } + } + + tag_specifications { + resource_type = "elastic-gpu" + + tags = { + Name = "test" + } + } } `, rName) //lintignore:AWSAT002 } diff --git a/website/docs/r/launch_template.html.markdown b/website/docs/r/launch_template.html.markdown index e3dc75ee024..69524c263ec 100644 --- a/website/docs/r/launch_template.html.markdown +++ b/website/docs/r/launch_template.html.markdown @@ -324,11 +324,11 @@ The `hibernation_options` block supports the following: ### Tag Specifications -The tags to apply to the resources during launch. You can tag instances and volumes. More information can be found in the [EC2 API documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_LaunchTemplateTagSpecificationRequest.html). +The tags to apply to the resources during launch. You can tag instances, volumes, elastic GPUs and spot instance requests. More information can be found in the [EC2 API documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_LaunchTemplateTagSpecificationRequest.html). Each `tag_specifications` block supports the following: -* `resource_type` - The type of resource to tag. Valid values are `instance` and `volume`. +* `resource_type` - The type of resource to tag. Valid values are `instance`, `volume`, `elastic-gpu` and `spot-instances-request`. * `tags` - A map of tags to assign to the resource.