Skip to content

Commit 91f94a4

Browse files
feat!: Upgrade AWS provider and min required Terraform version to 6.12 and 1.5.7 respectively (#45)
Co-authored-by: Anton Babenko <393243+antonbabenko@users.noreply.github.com>
1 parent 88f9595 commit 91f94a4

File tree

10 files changed

+385
-96
lines changed

10 files changed

+385
-96
lines changed

README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,20 @@ module "efs" {
5858
security_group_description = "Example EFS security group"
5959
security_group_vpc_id = "vpc-1234556abcdef"
6060
security_group_rules = {
61-
vpc = {
61+
vpc_1 = {
6262
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
6363
description = "NFS ingress from VPC private subnets"
64-
cidr_blocks = ["10.99.3.0/24", "10.99.4.0/24", "10.99.5.0/24"]
64+
cidr_ipv4 = "10.99.3.0/24"
65+
}
66+
vpc_2 = {
67+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
68+
description = "NFS ingress from VPC private subnets"
69+
cidr_ipv4 = "10.99.4.0/24"
70+
}
71+
vpc_3 = {
72+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
73+
description = "NFS ingress from VPC private subnets"
74+
cidr_ipv4 = "10.99.5.0/24"
6575
}
6676
}
6777
@@ -118,14 +128,14 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
118128

119129
| Name | Version |
120130
|------|---------|
121-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
122-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.35 |
131+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
132+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.12 |
123133

124134
## Providers
125135

126136
| Name | Version |
127137
|------|---------|
128-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.35 |
138+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.12 |
129139

130140
## Modules
131141

@@ -142,14 +152,15 @@ No modules.
142152
| [aws_efs_mount_target.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_mount_target) | resource |
143153
| [aws_efs_replication_configuration.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/efs_replication_configuration) | resource |
144154
| [aws_security_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource |
145-
| [aws_security_group_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource |
155+
| [aws_vpc_security_group_egress_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_egress_rule) | resource |
156+
| [aws_vpc_security_group_ingress_rule.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/vpc_security_group_ingress_rule) | resource |
146157
| [aws_iam_policy_document.policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
147158

148159
## Inputs
149160

150161
| Name | Description | Type | Default | Required |
151162
|------|-------------|------|---------|:--------:|
152-
| <a name="input_access_points"></a> [access\_points](#input\_access\_points) | A map of access point definitions to create | `any` | `{}` | no |
163+
| <a name="input_access_points"></a> [access\_points](#input\_access\_points) | A map of access point definitions to create | <pre>map(object({<br/> name = optional(string)<br/> tags = optional(map(string), {})<br/> posix_user = optional(object({<br/> gid = number<br/> uid = number<br/> secondary_gids = optional(list(number))<br/> }))<br/> root_directory = optional(object({<br/> path = optional(string)<br/> creation_info = optional(object({<br/> owner_gid = number<br/> owner_uid = number<br/> permissions = string<br/> }))<br/> }))<br/> }))</pre> | `{}` | no |
153164
| <a name="input_attach_policy"></a> [attach\_policy](#input\_attach\_policy) | Determines whether a policy is attached to the file system | `bool` | `true` | no |
154165
| <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 |
155166
| <a name="input_bypass_policy_lockout_safety_check"></a> [bypass\_policy\_lockout\_safety\_check](#input\_bypass\_policy\_lockout\_safety\_check) | A flag to indicate whether to bypass the `aws_efs_file_system_policy` lockout safety check. Defaults to `false` | `bool` | `null` | no |
@@ -163,18 +174,20 @@ No modules.
163174
| <a name="input_enable_backup_policy"></a> [enable\_backup\_policy](#input\_enable\_backup\_policy) | Determines whether a backup policy is `ENABLED` or `DISABLED` | `bool` | `true` | no |
164175
| <a name="input_encrypted"></a> [encrypted](#input\_encrypted) | If `true`, the disk will be encrypted | `bool` | `true` | no |
165176
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | The ARN for the KMS encryption key. When specifying `kms_key_arn`, encrypted needs to be set to `true` | `string` | `null` | no |
166-
| <a name="input_lifecycle_policy"></a> [lifecycle\_policy](#input\_lifecycle\_policy) | A file system [lifecycle policy](https://docs.aws.amazon.com/efs/latest/ug/API_LifecyclePolicy.html) object | `any` | `{}` | no |
167-
| <a name="input_mount_targets"></a> [mount\_targets](#input\_mount\_targets) | A map of mount target definitions to create | `any` | `{}` | no |
177+
| <a name="input_lifecycle_policy"></a> [lifecycle\_policy](#input\_lifecycle\_policy) | A file system [lifecycle policy](https://docs.aws.amazon.com/efs/latest/ug/API_LifecyclePolicy.html) object | <pre>object({<br/> transition_to_ia = optional(string)<br/> transition_to_archive = optional(string)<br/> transition_to_primary_storage_class = optional(string)<br/> })</pre> | `{}` | no |
178+
| <a name="input_mount_targets"></a> [mount\_targets](#input\_mount\_targets) | A map of mount target definitions to create | <pre>map(object({<br/> ip_address = optional(string)<br/> ip_address_type = optional(string)<br/> ipv6_address = optional(string)<br/> region = optional(string)<br/> security_groups = optional(list(string), [])<br/> subnet_id = string<br/> }))</pre> | `{}` | no |
168179
| <a name="input_name"></a> [name](#input\_name) | The name of the file system | `string` | `""` | no |
169180
| <a name="input_override_policy_documents"></a> [override\_policy\_documents](#input\_override\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. In merging, statements with non-blank `sid`s will override statements with the same `sid` | `list(string)` | `[]` | no |
170181
| <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` | `null` | no |
171-
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | A list of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permission usage | `any` | `[]` | no |
172-
| <a name="input_protection"></a> [protection](#input\_protection) | A map of file protection configurations | `any` | `{}` | no |
182+
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | A list of IAM policy [statements](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document#statement) for custom permission usage | <pre>map(object({<br/> sid = optional(string)<br/> actions = optional(list(string))<br/> not_actions = optional(list(string))<br/> effect = optional(string)<br/> resources = optional(list(string))<br/> not_resources = optional(list(string))<br/> principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> not_principals = optional(list(object({<br/> type = string<br/> identifiers = list(string)<br/> })))<br/> conditions = optional(list(object({<br/> test = string<br/> values = list(string)<br/> variable = string<br/> })))<br/> condition = optional(list(object({<br/> test = string<br/> values = list(string)<br/> variable = string<br/> })))<br/> }))</pre> | `null` | no |
183+
| <a name="input_protection"></a> [protection](#input\_protection) | A map of file protection configurations | <pre>object({<br/> replication_overwrite = optional(string)<br/> })</pre> | `null` | no |
173184
| <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 with `throughput_mode` set to `provisioned` | `number` | `null` | no |
174-
| <a name="input_replication_configuration_destination"></a> [replication\_configuration\_destination](#input\_replication\_configuration\_destination) | A destination configuration block | `any` | `{}` | no |
185+
| <a name="input_region"></a> [region](#input\_region) | Region where this resource will be managed. Defaults to the Region set in the provider configuration | `string` | `null` | no |
186+
| <a name="input_replication_configuration_destination"></a> [replication\_configuration\_destination](#input\_replication\_configuration\_destination) | A destination configuration block | <pre>object({<br/> availability_zone_name = optional(string)<br/> file_system_id = optional(string)<br/> kms_key_id = optional(string)<br/> region = optional(string)<br/> })</pre> | `null` | no |
175187
| <a name="input_security_group_description"></a> [security\_group\_description](#input\_security\_group\_description) | Security group description. Defaults to Managed by Terraform | `string` | `null` | no |
188+
| <a name="input_security_group_egress_rules"></a> [security\_group\_egress\_rules](#input\_security\_group\_egress\_rules) | Map of security group egress rules to add to the security group created | <pre>map(object({<br/> name = optional(string)<br/><br/> cidr_ipv4 = optional(string)<br/> cidr_ipv6 = optional(string)<br/> description = optional(string)<br/> from_port = optional(number, 2049)<br/> ip_protocol = optional(string, "tcp")<br/> prefix_list_id = optional(string)<br/> referenced_security_group_id = optional(string)<br/> region = optional(string)<br/> tags = optional(map(string), {})<br/> to_port = optional(number, 2049)<br/> }))</pre> | `{}` | no |
189+
| <a name="input_security_group_ingress_rules"></a> [security\_group\_ingress\_rules](#input\_security\_group\_ingress\_rules) | Map of security group ingress rules to add to the security group created | <pre>map(object({<br/> name = optional(string)<br/><br/> cidr_ipv4 = optional(string)<br/> cidr_ipv6 = optional(string)<br/> description = optional(string)<br/> from_port = optional(number, 2049)<br/> ip_protocol = optional(string, "tcp")<br/> prefix_list_id = optional(string)<br/> referenced_security_group_id = optional(string)<br/> region = optional(string)<br/> tags = optional(map(string), {})<br/> to_port = optional(number, 2049)<br/> }))</pre> | `{}` | no |
176190
| <a name="input_security_group_name"></a> [security\_group\_name](#input\_security\_group\_name) | Name to assign to the security group. If omitted, Terraform will assign a random, unique name | `string` | `null` | no |
177-
| <a name="input_security_group_rules"></a> [security\_group\_rules](#input\_security\_group\_rules) | Map of security group rule definitions to create | `any` | `{}` | no |
178191
| <a name="input_security_group_use_name_prefix"></a> [security\_group\_use\_name\_prefix](#input\_security\_group\_use\_name\_prefix) | Determines whether to use a name prefix for the security group. If `true`, the `security_group_name` value will be used as a prefix | `bool` | `false` | no |
179192
| <a name="input_security_group_vpc_id"></a> [security\_group\_vpc\_id](#input\_security\_group\_vpc\_id) | The VPC ID where the security group will be created | `string` | `null` | no |
180193
| <a name="input_source_policy_documents"></a> [source\_policy\_documents](#input\_source\_policy\_documents) | List of IAM policy documents that are merged together into the exported document. Statements must have unique `sid`s | `list(string)` | `[]` | no |

docs/UPGRADE-2.0.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Upgrade from v1.x to v2.x
2+
3+
Please consult the `examples` directory for reference example configurations. If you find a bug, please open an issue with supporting configuration to reproduce.
4+
5+
## List of backwards incompatible changes
6+
7+
- Terraform `v1.5.7` is now minimum supported version
8+
- AWS provider `v6.12` is now minimum supported version
9+
- `security_group_rules` has been split into `security_group_ingress_rules` and `security_group_egress_rules` to better match the AWS API and allow for more flexibility in defining security group rules.
10+
- `policy_statements` changed from type `any` to `map`
11+
12+
## Additional changes
13+
14+
### Added
15+
16+
- Support for `region` parameter to specify the AWS region for the resources created if different from the provider region.
17+
18+
### Modified
19+
20+
- Variable definitions now contain detailed `object` types in place of the previously used any type.
21+
22+
### Variable and output changes
23+
24+
1. Removed variables:
25+
26+
- `security_group_rules`
27+
28+
2. Renamed variables:
29+
30+
- None
31+
32+
3. Added variables:
33+
34+
- `security_group_ingress_rules`
35+
- `security_group_egress_rules`
36+
37+
4. Removed outputs:
38+
39+
- None
40+
41+
5. Renamed outputs:
42+
43+
- None
44+
45+
6. Added outputs:
46+
47+
- None
48+
49+
## Upgrade Migrations
50+
51+
### Before 2.x Example
52+
53+
```hcl
54+
module "efs" {
55+
source = "terraform-aws-modules/efs/aws"
56+
version = "~> 1.0"
57+
58+
# Truncated for brevity ...
59+
60+
# Security Groups
61+
security_group_rules = {
62+
vpc = {
63+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
64+
description = "NFS ingress from VPC private subnets"
65+
cidr_blocks = module.vpc.private_subnets_cidr_blocks
66+
}
67+
}
68+
69+
# EFS Policy Statements
70+
policy_statements = [
71+
{
72+
sid = "Example"
73+
actions = ["elasticfilesystem:ClientMount"]
74+
principals = [
75+
{
76+
type = "AWS"
77+
identifiers = [data.aws_caller_identity.current.arn]
78+
}
79+
]
80+
}
81+
]
82+
}
83+
```
84+
85+
### After 2.x Example
86+
87+
```hcl
88+
module "efs" {
89+
source = "terraform-aws-modules/efs/aws"
90+
version = "~> 2.0"
91+
92+
# Truncated for brevity ...
93+
94+
# Security Groups
95+
security_group_ingress_rules = {
96+
vpc_1 = {
97+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
98+
description = "NFS ingress from VPC private subnets"
99+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 0)
100+
}
101+
vpc_2 = {
102+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
103+
description = "NFS ingress from VPC private subnets"
104+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 1)
105+
}
106+
vpc_3 = {
107+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
108+
description = "NFS ingress from VPC private subnets"
109+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 2)
110+
}
111+
}
112+
113+
# EFS policy statements
114+
policy_statements = {
115+
example = {
116+
sid = "Example"
117+
actions = ["elasticfilesystem:ClientMount"]
118+
principals = [
119+
{
120+
type = "AWS"
121+
identifiers = [data.aws_caller_identity.current.arn]
122+
}
123+
]
124+
}
125+
}
126+
}
127+
```
128+
129+
### State Changes
130+
131+
Due to the change from `aws_security_group_rule` to `aws_vpc_security_group_ingress_rule` and `aws_vpc_security_group_egress_rule`, the following reference state changes are required to maintain the current security group rules. (Note: these are different resources so they cannot be moved with `terraform mv ...`)
132+
133+
```sh
134+
terraform state rm 'module.efs.aws_security_group_rule.this["vpc"]'
135+
terraform state import 'module.efs.aws_vpc_security_group_ingress_rule.this["vpc_1"]' 'sg-xxx'
136+
terraform state import 'module.efs.aws_vpc_security_group_ingress_rule.this["vpc_2"]' 'sg-xxx'
137+
terraform state import 'module.efs.aws_vpc_security_group_ingress_rule.this["vpc_3"]' 'sg-xxx'
138+
```

examples/complete/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ Note that this example may create resources which will incur monetary charges on
2323

2424
| Name | Version |
2525
|------|---------|
26-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
27-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.35 |
26+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5.7 |
27+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 6.12 |
2828

2929
## Providers
3030

3131
| Name | Version |
3232
|------|---------|
33-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.35 |
33+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 6.12 |
3434

3535
## Modules
3636

@@ -40,7 +40,7 @@ Note that this example may create resources which will incur monetary charges on
4040
| <a name="module_efs_default"></a> [efs\_default](#module\_efs\_default) | ../.. | n/a |
4141
| <a name="module_efs_disabled"></a> [efs\_disabled](#module\_efs\_disabled) | ../.. | n/a |
4242
| <a name="module_kms"></a> [kms](#module\_kms) | terraform-aws-modules/kms/aws | ~> 1.0 |
43-
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 5.0 |
43+
| <a name="module_vpc"></a> [vpc](#module\_vpc) | terraform-aws-modules/vpc/aws | ~> 6.0 |
4444

4545
## Resources
4646

examples/complete/main.tf

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ module "efs" {
4545
attach_policy = true
4646
deny_nonsecure_transport_via_mount_target = false
4747
bypass_policy_lockout_safety_check = false
48-
policy_statements = [
49-
{
48+
policy_statements = {
49+
example = {
5050
sid = "Example"
5151
actions = ["elasticfilesystem:ClientMount"]
5252
principals = [
@@ -56,17 +56,27 @@ module "efs" {
5656
}
5757
]
5858
}
59-
]
59+
}
6060

6161
# Mount targets / security group
6262
mount_targets = { for k, v in zipmap(local.azs, module.vpc.private_subnets) : k => { subnet_id = v } }
6363
security_group_description = "Example EFS security group"
6464
security_group_vpc_id = module.vpc.vpc_id
65-
security_group_rules = {
66-
vpc = {
65+
security_group_ingress_rules = {
66+
vpc_1 = {
67+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
68+
description = "NFS ingress from VPC private subnets"
69+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 0)
70+
}
71+
vpc_2 = {
72+
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
73+
description = "NFS ingress from VPC private subnets"
74+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 1)
75+
}
76+
vpc_3 = {
6777
# relying on the defaults provided for EFS/NFS (2049/TCP + ingress)
6878
description = "NFS ingress from VPC private subnets"
69-
cidr_blocks = module.vpc.private_subnets_cidr_blocks
79+
cidr_ipv4 = element(module.vpc.private_subnets_cidr_blocks, 2)
7080
}
7181
}
7282

@@ -128,7 +138,7 @@ module "efs_disabled" {
128138

129139
module "vpc" {
130140
source = "terraform-aws-modules/vpc/aws"
131-
version = "~> 5.0"
141+
version = "~> 6.0"
132142

133143
name = local.name
134144
cidr = "10.99.0.0/18"

examples/complete/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1.0"
2+
required_version = ">= 1.5.7"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 5.35"
7+
version = ">= 6.12"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)