Skip to content

Commit

Permalink
docs(UPGRADE.md): update upgrade guide with detailed state migration …
Browse files Browse the repository at this point in the history
…steps and verification process for EFS module upgrade
  • Loading branch information
sachincool committed Nov 13, 2024
1 parent 071e7d0 commit acf862c
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,42 @@ This guide helps you upgrade the EFS module from version v0.3.5 and below to new

### Required Actions

Before running `terraform plan`, you need to migrate the state of the EFS filesystem resource to prevent destruction and recreation. Execute the following command:
1. First, create a backup of your terraform state:

```bash
terraform state mv 'module.efs.module.efs.aws_efs_file_system.default[0]' 'module.efs.module.efs.aws_efs_file_system.this[0]'
# For local state
terraform state pull > terraform.tfstate.backup.$(date +%Y%m%d_%H%M%S)
```

2. Before running `terraform plan`, you need to migrate the state of the EFS resources to prevent destruction and recreation. Execute the following commands in order:

```bash
# Move EFS file system
terraform state mv 'module.efs.module.efs.aws_efs_file_system.default[0]' 'module.efs.module.efs.aws_efs_file_system.this[0]'

# Move mount targets
terraform state mv 'module.efs.module.efs.aws_efs_mount_target.default[0]' 'module.efs.module.efs.aws_efs_mount_target.this[0]'
terraform state mv 'module.efs.module.efs.aws_efs_mount_target.default[1]' 'module.efs.module.efs.aws_efs_mount_target.this[1]'
terraform state mv 'module.efs.module.efs.aws_efs_mount_target.default[2]' 'module.efs.module.efs.aws_efs_mount_target.this[2]'

# Move file system policy
terraform state mv 'module.efs.aws_efs_file_system_policy.default' 'module.efs.aws_efs_file_system_policy.this'

# Move backup policy
terraform state mv 'module.efs.module.efs.aws_efs_backup_policy.default[0]' 'module.efs.module.efs.aws_efs_backup_policy.policy[0]'

### Verification Steps

1. Run all the state move commands mentioned above
2. Execute `terraform plan`
3. Verify that the plan does not show destruction of any EFS resources
4. The plan should only show changes related to the resource name changes
5. If the plan shows EFS resource destruction, DO NOT APPLY and review the state migration steps

### Notes

- Always backup your Terraform state before performing any state migrations
- Test these changes in a non-production environment first
- If you encounter any issues during the upgrade, please refer to the module documentation or open an issue in the repository
- Make sure to execute the state move commands in the order specified above
- If you have a different number of mount targets, adjust the mount target migration commands accordingly

0 comments on commit acf862c

Please sign in to comment.