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

r/launch_template - add support for "spot-instances-request" and "elastic-gpu" tag spec #14662

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions aws/resource_aws_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,8 @@ func resourceAwsLaunchTemplate() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, per #14601 and the EC2 API documentation we may want to consider flipping this to the new AWS Go SDK ec2.ResourceType_Values() function to reduce manual maintenance here. 👍

ec2.ResourceTypeInstance,
ec2.ResourceTypeVolume,
ec2.ResourceTypeSpotInstancesRequest,
ec2.ResourceTypeElasticGpu,
}, false),
},
"tags": tagsSchema(),
Expand Down
26 changes: 25 additions & 1 deletion aws/resource_aws_launch_template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
{
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions website/docs/r/launch_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down