Skip to content

Commit b07f17d

Browse files
feat: Enhance EFS module documentation and variable requirements for clarity and consistency
1 parent 4277eab commit b07f17d

File tree

12 files changed

+155
-57
lines changed

12 files changed

+155
-57
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -521,13 +521,13 @@ No modules.
521521

522522
| Name | Description | Type | Default | Required |
523523
|------|-------------|------|---------|:--------:|
524-
| <a name="input_creation_token"></a> [creation\_token](#input\_creation\_token) | A unique name used as reference when creating the EFS | `string` | n/a | yes |
525-
| <a name="input_name"></a> [name](#input\_name) | Optional name for the EFS file system. If provided, will be added as a 'Name' tag | `string` | `null` | no |
524+
| <a name="input_creation_token"></a> [creation\_token](#input\_creation\_token) | Required unique identifier for the EFS file system. Must be unique within your AWS account and region and cannot be empty | `string` | n/a | yes |
525+
| <a name="input_name"></a> [name](#input\_name) | Required friendly name for the EFS file system. Will be added as a 'Name' tag and cannot be empty | `string` | n/a | yes |
526526
| <a name="input_availability_zone_name"></a> [availability\_zone\_name](#input\_availability\_zone\_name) | The AWS Availability Zone in which to create the file system. Used to create a file system that uses One Zone storage classes. If omitted, Multi-AZ storage will be used | `string` | `null` | no |
527527
| <a name="input_encrypted"></a> [encrypted](#input\_encrypted) | If true, the disk will be encrypted | `bool` | `true` | no |
528528
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | ARN for the KMS encryption key. If set, the EFS file system will be encrypted at rest using this key | `string` | `null` | no |
529-
| <a name="input_performance_mode"></a> [performance\_mode](#input\_performance\_mode) | The file system performance mode. Can be either 'generalPurpose' or 'maxIO'. Default is 'generalPurpose' | `string` | `"generalPurpose"` | no |
530-
| <a name="input_throughput_mode"></a> [throughput\_mode](#input\_throughput\_mode) | Throughput mode for the file system. Valid values: 'bursting', 'provisioned', or 'elastic'. When using 'provisioned', also set provisioned\_throughput\_in\_mibps | `string` | `"bursting"` | no |
529+
| <a name="input_performance_mode"></a> [performance\_mode](#input\_performance\_mode) | The file system performance mode. Valid values: 'generalPurpose' (default, lower latency for most workloads) or 'maxIO' (higher aggregate throughput for highly parallelized workloads) | `string` | `"generalPurpose"` | no |
530+
| <a name="input_throughput_mode"></a> [throughput\_mode](#input\_throughput\_mode) | Throughput mode for the file system. Valid values: 'bursting' (scales with file system size), 'elastic' (automatically scales based on workload), or 'provisioned' (fixed throughput - requires provisioned\_throughput\_in\_mibps to be set) | `string` | `"bursting"` | no |
531531
| <a name="input_provisioned_throughput_in_mibps"></a> [provisioned\_throughput\_in\_mibps](#input\_provisioned\_throughput\_in\_mibps) | The throughput, measured in MiB/s, that you want to provision for the file system. Only applicable when throughput\_mode is set to 'provisioned' | `number` | `null` | no |
532532
| <a name="input_lifecycle_policy"></a> [lifecycle\_policy](#input\_lifecycle\_policy) | Lifecycle policy for the file system. Supports transition\_to\_ia (AFTER\_7\_DAYS, AFTER\_14\_DAYS, AFTER\_30\_DAYS, AFTER\_60\_DAYS, AFTER\_90\_DAYS, AFTER\_1\_DAY, AFTER\_180\_DAYS, AFTER\_270\_DAYS, AFTER\_365\_DAYS), transition\_to\_primary\_storage\_class (AFTER\_1\_ACCESS), and transition\_to\_archive (AFTER\_1\_DAY, AFTER\_7\_DAYS, AFTER\_14\_DAYS, AFTER\_30\_DAYS, AFTER\_60\_DAYS, AFTER\_90\_DAYS, AFTER\_180\_DAYS, AFTER\_270\_DAYS, AFTER\_365\_DAYS) | <pre>object({<br/> transition_to_ia = optional(string)<br/> transition_to_primary_storage_class = optional(string)<br/> transition_to_archive = optional(string)<br/> })</pre> | `null` | no |
533533
| <a name="input_protection"></a> [protection](#input\_protection) | Protection configuration for the file system. Supports replication\_overwrite (ENABLED, DISABLED, REPLICATING) | <pre>object({<br/> replication_overwrite = optional(string)<br/> })</pre> | `null` | no |

examples/complete/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,19 @@ No resources.
288288

289289
| Name | Description | Type | Default | Required |
290290
|------|-------------|------|---------|:--------:|
291-
| <a name="input_logical_product_family"></a> [logical\_product\_family](#input\_logical\_product\_family) | Logical product family name for naming convention | `string` | n/a | yes |
292-
| <a name="input_logical_product_service"></a> [logical\_product\_service](#input\_logical\_product\_service) | Logical product service name for naming convention | `string` | n/a | yes |
293-
| <a name="input_class_env"></a> [class\_env](#input\_class\_env) | Environment class for naming convention (e.g., sandbox, dev, prod) | `string` | n/a | yes |
294-
| <a name="input_instance_env"></a> [instance\_env](#input\_instance\_env) | Environment instance number for naming convention | `number` | n/a | yes |
295-
| <a name="input_instance_resource"></a> [instance\_resource](#input\_instance\_resource) | Resource instance number for naming convention | `number` | n/a | yes |
296-
| <a name="input_region"></a> [region](#input\_region) | AWS region for naming convention | `string` | n/a | yes |
297-
| <a name="input_resource_names_map"></a> [resource\_names\_map](#input\_resource\_names\_map) | Map of resource types to their configurations for name generation | <pre>map(object({<br/> name = string<br/> max_length = optional(number, 60)<br/> }))</pre> | `{}` | no |
298-
| <a name="input_creation_token"></a> [creation\_token](#input\_creation\_token) | A unique name used as reference when creating the EFS. If null, will use generated name from resource\_names module | `string` | `null` | no |
299-
| <a name="input_name"></a> [name](#input\_name) | Optional name for the EFS file system. If provided, will be added as a 'Name' tag. If null, will use generated name from resource\_names module | `string` | `null` | no |
291+
| <a name="input_logical_product_family"></a> [logical\_product\_family](#input\_logical\_product\_family) | (Required) Name of the product family for which the resource is created.<br/> Example: org\_name, department\_name. | `string` | `"launch"` | no |
292+
| <a name="input_logical_product_service"></a> [logical\_product\_service](#input\_logical\_product\_service) | (Required) Name of the product service for which the resource is created.<br/> For example, backend, frontend, middleware etc. | `string` | `"backend"` | no |
293+
| <a name="input_instance_resource"></a> [instance\_resource](#input\_instance\_resource) | Number that represents the instance of the resource. | `number` | `0` | no |
294+
| <a name="input_instance_env"></a> [instance\_env](#input\_instance\_env) | Number that represents the instance of the environment. | `number` | `0` | no |
295+
| <a name="input_class_env"></a> [class\_env](#input\_class\_env) | (Required) Environment where resource is going to be deployed. For example. dev, qa, uat | `string` | `"dev"` | no |
296+
| <a name="input_resource_names_map"></a> [resource\_names\_map](#input\_resource\_names\_map) | A map of key to resource\_name that will be used by tf-launch-module\_library-resource\_name to generate resource names | <pre>map(object(<br/> {<br/> name = string<br/> max_length = optional(number, 60)<br/> }<br/> ))</pre> | `{}` | no |
297+
| <a name="input_region"></a> [region](#input\_region) | (Required) The location where the resource will be created. Must not have spaces<br/> For example, us-east-1, us-west-2, eu-west-1, etc. | `string` | `"us-east-2"` | no |
298+
| <a name="input_creation_token"></a> [creation\_token](#input\_creation\_token) | Optional unique identifier for the EFS file system. If not provided, will use the generated or provided name value | `string` | `null` | no |
299+
| <a name="input_name"></a> [name](#input\_name) | Optional name for the EFS file system. If not provided, a generated name from resource\_names module will be used | `string` | `null` | no |
300300
| <a name="input_availability_zone_name"></a> [availability\_zone\_name](#input\_availability\_zone\_name) | The AWS Availability Zone in which to create the file system. Used to create a file system that uses One Zone storage classes | `string` | `null` | no |
301301
| <a name="input_encrypted"></a> [encrypted](#input\_encrypted) | If true, the disk will be encrypted | `bool` | `true` | no |
302302
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | ARN for the KMS encryption key. If set, the EFS file system will be encrypted at rest using this key | `string` | `null` | no |
303-
| <a name="input_performance_mode"></a> [performance\_mode](#input\_performance\_mode) | The file system performance mode. Can be either 'generalPurpose' or 'maxIO' | `string` | `"generalPurpose"` | no |
303+
| <a name="input_performance_mode"></a> [performance\_mode](#input\_performance\_mode) | The file system performance mode. Valid values: 'generalPurpose' (default, lower latency) or 'maxIO' (higher aggregate throughput) | `string` | `"generalPurpose"` | no |
304304
| <a name="input_throughput_mode"></a> [throughput\_mode](#input\_throughput\_mode) | Throughput mode for the file system. Valid values: 'bursting', 'provisioned', or 'elastic' | `string` | `"elastic"` | no |
305305
| <a name="input_provisioned_throughput_in_mibps"></a> [provisioned\_throughput\_in\_mibps](#input\_provisioned\_throughput\_in\_mibps) | The throughput, measured in MiB/s, that you want to provision for the file system. Only applicable when throughput\_mode is set to 'provisioned' | `number` | `null` | no |
306306
| <a name="input_lifecycle_policy"></a> [lifecycle\_policy](#input\_lifecycle\_policy) | Lifecycle policy for the file system | <pre>object({<br/> transition_to_ia = optional(string)<br/> transition_to_primary_storage_class = optional(string)<br/> transition_to_archive = optional(string)<br/> })</pre> | <pre>{<br/> "transition_to_archive": "AFTER_90_DAYS",<br/> "transition_to_ia": "AFTER_30_DAYS",<br/> "transition_to_primary_storage_class": "AFTER_1_ACCESS"<br/>}</pre> | no |

examples/complete/local.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed under the Apache License, Version 2.0 (the "License");
2+
// you may not use this file except in compliance with the License.
3+
// You may obtain a copy of the License at
4+
//
5+
// http://www.apache.org/licenses/LICENSE-2.0
6+
//
7+
// Unless required by applicable law or agreed to in writing, software
8+
// distributed under the License is distributed on an "AS IS" BASIS,
9+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
// See the License for the specific language governing permissions and
11+
// limitations under the License.
12+
13+
locals {
14+
# Generate the EFS name: use provided name or fall back to resource_names module output
15+
efs_name = var.name != null ? var.name : module.resource_names["efs"].standard
16+
17+
# Generate the creation token: use provided value or fall back to the EFS name
18+
creation_token = var.creation_token != null ? var.creation_token : local.efs_name
19+
}

examples/complete/main.tf

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,26 @@ module "resource_names" {
4444

4545
logical_product_family = var.logical_product_family
4646
logical_product_service = var.logical_product_service
47-
region = var.region
47+
region = join("", split("-", var.region))
4848
class_env = var.class_env
4949
cloud_resource_type = each.value.name
5050
instance_env = var.instance_env
51-
maximum_length = each.value.max_length
5251
instance_resource = var.instance_resource
52+
maximum_length = each.value.max_length
5353
}
5454

55+
5556
module "efs_complete" {
5657
source = "../../"
5758

5859
# Unique identifier for the EFS file system within AWS account and region
59-
# Uses var.creation_token if provided, otherwise uses generated name from resource_names module
60-
creation_token = try(var.creation_token, module.resource_names["efs"].standard)
60+
# Uses var.creation_token if provided, otherwise uses the EFS name
61+
creation_token = local.creation_token
6162

6263
# Friendly name for AWS Console identification
6364
# Automatically creates a 'Name' tag
6465
# Uses var.name if provided, otherwise uses generated name from resource_names module
65-
name = try(var.name, module.resource_names["efs"].standard)
66+
name = local.efs_name
6667

6768
# Optional: Specify an Availability Zone for One Zone storage class
6869
# Leave null (default) for Multi-AZ storage with high availability

examples/complete/variables.tf

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,104 @@
1212

1313
# Naming Module Variables
1414
variable "logical_product_family" {
15-
description = "Logical product family name for naming convention"
1615
type = string
16+
description = <<EOF
17+
(Required) Name of the product family for which the resource is created.
18+
Example: org_name, department_name.
19+
EOF
20+
nullable = false
21+
default = "launch"
22+
23+
validation {
24+
condition = can(regex("^[_\\-A-Za-z0-9]+$", var.logical_product_family))
25+
error_message = "The variable must contain letters, numbers, -, _, and .."
26+
}
1727
}
1828

1929
variable "logical_product_service" {
20-
description = "Logical product service name for naming convention"
2130
type = string
31+
description = <<EOF
32+
(Required) Name of the product service for which the resource is created.
33+
For example, backend, frontend, middleware etc.
34+
EOF
35+
nullable = false
36+
default = "backend"
37+
38+
validation {
39+
condition = can(regex("^[_\\-A-Za-z0-9]+$", var.logical_product_service))
40+
error_message = "The variable must contain letters, numbers, -, _, and .."
41+
}
2242
}
2343

24-
variable "class_env" {
25-
description = "Environment class for naming convention (e.g., sandbox, dev, prod)"
26-
type = string
44+
variable "instance_resource" {
45+
type = number
46+
description = "Number that represents the instance of the resource."
47+
default = 0
48+
49+
validation {
50+
condition = var.instance_resource >= 0 && var.instance_resource <= 100
51+
error_message = "Instance number should be between 1 to 100."
52+
}
2753
}
2854

2955
variable "instance_env" {
30-
description = "Environment instance number for naming convention"
3156
type = number
32-
}
57+
description = "Number that represents the instance of the environment."
58+
default = 0
3359

34-
variable "instance_resource" {
35-
description = "Resource instance number for naming convention"
36-
type = number
60+
validation {
61+
condition = var.instance_env >= 0 && var.instance_env <= 999
62+
error_message = "Instance number should be between 1 to 999."
63+
}
3764
}
3865

39-
variable "region" {
40-
description = "AWS region for naming convention"
66+
variable "class_env" {
4167
type = string
68+
default = "dev"
69+
description = "(Required) Environment where resource is going to be deployed. For example. dev, qa, uat"
70+
nullable = false
71+
72+
validation {
73+
condition = length(regexall("\\b \\b", var.class_env)) == 0
74+
error_message = "Spaces between the words are not allowed."
75+
}
4276
}
4377

4478
variable "resource_names_map" {
45-
description = "Map of resource types to their configurations for name generation"
46-
type = map(object({
47-
name = string
48-
max_length = optional(number, 60)
49-
}))
79+
description = "A map of key to resource_name that will be used by tf-launch-module_library-resource_name to generate resource names"
80+
type = map(object(
81+
{
82+
name = string
83+
max_length = optional(number, 60)
84+
}
85+
))
5086
default = {}
5187
}
5288

89+
variable "region" {
90+
type = string
91+
description = <<EOF
92+
(Required) The location where the resource will be created. Must not have spaces
93+
For example, us-east-1, us-west-2, eu-west-1, etc.
94+
EOF
95+
nullable = false
96+
default = "us-east-2"
97+
98+
validation {
99+
condition = length(regexall("\\b \\b", var.region)) == 0
100+
error_message = "Spaces between the words are not allowed."
101+
}
102+
}
103+
104+
# EFS File System Variables
53105
variable "creation_token" {
54-
description = "A unique name used as reference when creating the EFS. If null, will use generated name from resource_names module"
106+
description = "Optional unique identifier for the EFS file system. If not provided, will use the generated or provided name value"
55107
type = string
56108
default = null
57109
}
58110

59111
variable "name" {
60-
description = "Optional name for the EFS file system. If provided, will be added as a 'Name' tag. If null, will use generated name from resource_names module"
112+
description = "Optional name for the EFS file system. If not provided, a generated name from resource_names module will be used"
61113
type = string
62114
default = null
63115
}
@@ -81,7 +133,7 @@ variable "kms_key_id" {
81133
}
82134

83135
variable "performance_mode" {
84-
description = "The file system performance mode. Can be either 'generalPurpose' or 'maxIO'"
136+
description = "The file system performance mode. Valid values: 'generalPurpose' (default, lower latency) or 'maxIO' (higher aggregate throughput)"
85137
type = string
86138
default = "generalPurpose"
87139
}

examples/simple/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ No resources.
156156
| <a name="input_instance_resource"></a> [instance\_resource](#input\_instance\_resource) | Resource instance number for naming convention | `number` | n/a | yes |
157157
| <a name="input_region"></a> [region](#input\_region) | AWS region for naming convention | `string` | n/a | yes |
158158
| <a name="input_resource_names_map"></a> [resource\_names\_map](#input\_resource\_names\_map) | Map of resource types to their configurations for name generation | <pre>map(object({<br/> name = string<br/> max_length = optional(number, 60)<br/> }))</pre> | `{}` | no |
159-
| <a name="input_creation_token"></a> [creation\_token](#input\_creation\_token) | A unique name used as reference when creating the EFS. If null, will use generated name from resource\_names module | `string` | `null` | no |
160-
| <a name="input_name"></a> [name](#input\_name) | Optional name for the EFS file system. If provided, will be added as a 'Name' tag. If null, will use generated name from resource\_names module | `string` | `null` | no |
159+
| <a name="input_creation_token"></a> [creation\_token](#input\_creation\_token) | Optional unique identifier for the EFS file system. If not provided, will use the generated or provided name value | `string` | `null` | no |
160+
| <a name="input_name"></a> [name](#input\_name) | Optional name for the EFS file system. If not provided, a generated name from resource\_names module will be used | `string` | `null` | no |
161161
| <a name="input_encrypted"></a> [encrypted](#input\_encrypted) | If true, the disk will be encrypted | `bool` | `true` | no |
162162
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | ARN for the KMS encryption key. Required if encrypted is true | `string` | `null` | no |
163-
| <a name="input_performance_mode"></a> [performance\_mode](#input\_performance\_mode) | The file system performance mode | `string` | `"generalPurpose"` | no |
164-
| <a name="input_throughput_mode"></a> [throughput\_mode](#input\_throughput\_mode) | Throughput mode for the file system | `string` | `"bursting"` | no |
163+
| <a name="input_performance_mode"></a> [performance\_mode](#input\_performance\_mode) | The file system performance mode. Valid values: 'generalPurpose' (default, lower latency) or 'maxIO' (higher aggregate throughput) | `string` | `"generalPurpose"` | no |
164+
| <a name="input_throughput_mode"></a> [throughput\_mode](#input\_throughput\_mode) | Throughput mode for the file system. Valid values: 'bursting' (scales with file system size), 'elastic' (auto-scaling), or 'provisioned' (fixed throughput) | `string` | `"bursting"` | no |
165165
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the EFS file system | `map(string)` | <pre>{<br/> "Environment": "dev",<br/> "Example": "simple"<br/>}</pre> | no |
166166

167167
## Outputs

0 commit comments

Comments
 (0)