Skip to content

Commit ad5f77e

Browse files
authored
Support spread_level for placement-group module (#2)
1 parent eed7fb8 commit ad5f77e

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

modules/placement-group/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ This module creates following resources.
1212
| Name | Version |
1313
|------|---------|
1414
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2 |
15-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.20 |
15+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.22 |
1616

1717
## Providers
1818

1919
| Name | Version |
2020
|------|---------|
21-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.14.0 |
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.23.0 |
2222

2323
## Modules
2424

@@ -42,6 +42,7 @@ No modules.
4242
| <a name="input_resource_group_description"></a> [resource\_group\_description](#input\_resource\_group\_description) | (Optional) The description of Resource Group. | `string` | `"Managed by Terraform."` | no |
4343
| <a name="input_resource_group_enabled"></a> [resource\_group\_enabled](#input\_resource\_group\_enabled) | (Optional) Whether to create Resource Group to find and group AWS resources which are created by this module. | `bool` | `true` | no |
4444
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | (Optional) The name of Resource Group. A Resource Group name can have a maximum of 127 characters, including letters, numbers, hyphens, dots, and underscores. The name cannot start with `AWS` or `aws`. | `string` | `""` | no |
45+
| <a name="input_spread_level"></a> [spread\_level](#input\_spread\_level) | (Optional) The spread level to determine how the placement group spread instances. Can only be specified when the `strategy` is set to `SPREAD`. Valid values are `HOST` and `RACK`. `HOST` can only be used for Outpost placement groups. | `string` | `"RACK"` | no |
4546
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to add to all resources. | `map(string)` | `{}` | no |
4647

4748
## Outputs
@@ -52,5 +53,6 @@ No modules.
5253
| <a name="output_id"></a> [id](#output\_id) | The ID of the placement group. |
5354
| <a name="output_name"></a> [name](#output\_name) | The name of the placement group. |
5455
| <a name="output_partition_size"></a> [partition\_size](#output\_partition\_size) | The number of partitions in the placement group. Only configured when the `strategy` is `PARTITION`. |
56+
| <a name="output_spread_level"></a> [spread\_level](#output\_spread\_level) | The spread level to determine how the placement group spread instance. Only configured when the `strategy` is `SPREAD`. |
5557
| <a name="output_strategy"></a> [strategy](#output\_strategy) | The placement strategy. |
5658
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

modules/placement-group/main.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ resource "aws_placement_group" "this" {
3434
? var.partition_size
3535
: null
3636
)
37+
spread_level = (var.strategy == "SPREAD"
38+
? lower(var.spread_level)
39+
: null
40+
)
3741

3842
tags = merge(
3943
{

modules/placement-group/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@ output "partition_size" {
2222
description = "The number of partitions in the placement group. Only configured when the `strategy` is `PARTITION`."
2323
value = aws_placement_group.this.partition_count
2424
}
25+
26+
output "spread_level" {
27+
description = "The spread level to determine how the placement group spread instance. Only configured when the `strategy` is `SPREAD`."
28+
value = upper(aws_placement_group.this.spread_level)
29+
}

modules/placement-group/variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ variable "partition_size" {
2626
nullable = false
2727
}
2828

29+
variable "spread_level" {
30+
description = "(Optional) The spread level to determine how the placement group spread instances. Can only be specified when the `strategy` is set to `SPREAD`. Valid values are `HOST` and `RACK`. `HOST` can only be used for Outpost placement groups."
31+
type = string
32+
default = "RACK"
33+
nullable = false
34+
35+
validation {
36+
condition = contains(["HOST", "RACK"], var.spread_level)
37+
error_message = "Valid values are `HOST`, or `RACK`."
38+
}
39+
}
40+
2941
variable "tags" {
3042
description = "(Optional) A map of tags to add to all resources."
3143
type = map(string)

modules/placement-group/versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 4.20"
7+
version = ">= 4.22"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)