Skip to content

Commit

Permalink
Merge branch '15784-aws_launch_template-host_resource_group_arn' of s…
Browse files Browse the repository at this point in the history
…sh://github.com/preflightsiren/terraform-provider-aws into preflightsiren-15784-aws_launch_template-host_resource_group_arn
  • Loading branch information
bflad committed Apr 28, 2021
2 parents 5d04b68 + 0ffe05c commit 6c5471c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
4 changes: 4 additions & 0 deletions aws/data_source_aws_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ func dataSourceAwsLaunchTemplate() *schema.Resource {
Type: schema.TypeString,
Computed: true,
},
"host_resource_group_arn": {
Type: schema.TypeString,
Computed: true,
},
"spread_domain": {
Type: schema.TypeString,
Computed: true,
Expand Down
25 changes: 18 additions & 7 deletions aws/resource_aws_launch_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,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,
Expand Down Expand Up @@ -1243,13 +1249,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
Expand Down Expand Up @@ -1842,6 +1849,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)
}
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/launch_template.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,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.
Expand Down

0 comments on commit 6c5471c

Please sign in to comment.