From d6d36c253d33b06eb8ffa6e368029d5a30d79858 Mon Sep 17 00:00:00 2001 From: Sebastian Cole Date: Thu, 22 Oct 2020 16:00:12 +1100 Subject: [PATCH 1/2] Adding minimum to support host_resource_group_arn --- aws/data_source_aws_launch_template.go | 4 ++++ aws/resource_aws_launch_template.go | 25 ++++++++++++++------ website/docs/r/launch_template.html.markdown | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/aws/data_source_aws_launch_template.go b/aws/data_source_aws_launch_template.go index 3c4f27dad4e..ff608e8d9a4 100644 --- a/aws/data_source_aws_launch_template.go +++ b/aws/data_source_aws_launch_template.go @@ -314,6 +314,10 @@ func dataSourceAwsLaunchTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, + "host_resource_group_arn": { + Type: schema.TypeString, + Optional: true, + }, "spread_domain": { Type: schema.TypeString, Computed: true, diff --git a/aws/resource_aws_launch_template.go b/aws/resource_aws_launch_template.go index 9b41755ab3c..2534f6846fc 100644 --- a/aws/resource_aws_launch_template.go +++ b/aws/resource_aws_launch_template.go @@ -510,6 +510,12 @@ func resourceAwsLaunchTemplate() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "host_resource_group_arn": { + Type: schema.TypeString, + Optional: true, + ConflictsWith: []string{"placement.0.host_id"}, + ValidateFunc: validateArn, + }, "spread_domain": { Type: schema.TypeString, Optional: true, @@ -1183,13 +1189,14 @@ func getPlacement(p *ec2.LaunchTemplatePlacement) []interface{} { var s []interface{} if p != nil { s = append(s, map[string]interface{}{ - "affinity": aws.StringValue(p.Affinity), - "availability_zone": aws.StringValue(p.AvailabilityZone), - "group_name": aws.StringValue(p.GroupName), - "host_id": aws.StringValue(p.HostId), - "spread_domain": aws.StringValue(p.SpreadDomain), - "tenancy": aws.StringValue(p.Tenancy), - "partition_number": aws.Int64Value(p.PartitionNumber), + "affinity": aws.StringValue(p.Affinity), + "availability_zone": aws.StringValue(p.AvailabilityZone), + "group_name": aws.StringValue(p.GroupName), + "host_id": aws.StringValue(p.HostId), + "host_resource_group_arn": aws.StringValue(p.HostResourceGroupArn), + "spread_domain": aws.StringValue(p.SpreadDomain), + "tenancy": aws.StringValue(p.Tenancy), + "partition_number": aws.Int64Value(p.PartitionNumber), }) } return s @@ -1759,6 +1766,10 @@ func readPlacementFromConfig(p map[string]interface{}) *ec2.LaunchTemplatePlacem placement.HostId = aws.String(v) } + if v, ok := p["host_resource_group_arn"].(string); ok && v != "" { + placement.HostResourceGroupArn = aws.String(v) + } + if v, ok := p["spread_domain"].(string); ok && v != "" { placement.SpreadDomain = aws.String(v) } diff --git a/website/docs/r/launch_template.html.markdown b/website/docs/r/launch_template.html.markdown index 0b68121518f..f4f89057f6e 100644 --- a/website/docs/r/launch_template.html.markdown +++ b/website/docs/r/launch_template.html.markdown @@ -312,6 +312,7 @@ The `placement` block supports the following: * `availability_zone` - The Availability Zone for the instance. * `group_name` - The name of the placement group for the instance. * `host_id` - The ID of the Dedicated Host for the instance. +* `host_resource_group_arn` - The ARN of the Host Resource Group in which to launch instances. * `spread_domain` - Reserved for future use. * `tenancy` - The tenancy of the instance (if the instance is running in a VPC). Can be `default`, `dedicated`, or `host`. * `partition_number` - The number of the partition the instance should launch in. Valid only if the placement group strategy is set to partition. From 0ffe05cda7df8e9e6873804074e2d2520ca66b4a Mon Sep 17 00:00:00 2001 From: Brian Flad Date: Wed, 28 Apr 2021 15:30:43 -0400 Subject: [PATCH 2/2] Update aws/data_source_aws_launch_template.go --- aws/data_source_aws_launch_template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aws/data_source_aws_launch_template.go b/aws/data_source_aws_launch_template.go index ff608e8d9a4..a8efa3e3d0b 100644 --- a/aws/data_source_aws_launch_template.go +++ b/aws/data_source_aws_launch_template.go @@ -316,7 +316,7 @@ func dataSourceAwsLaunchTemplate() *schema.Resource { }, "host_resource_group_arn": { Type: schema.TypeString, - Optional: true, + Computed: true, }, "spread_domain": { Type: schema.TypeString,