From acf862c24cf262cb36b419ac76a7948508c4d19f Mon Sep 17 00:00:00 2001 From: Harshit Luthra Date: Wed, 13 Nov 2024 13:37:54 +0530 Subject: [PATCH] docs(UPGRADE.md): update upgrade guide with detailed state migration steps and verification process for EFS module upgrade --- UPGRADE.md | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 6c93493..f535e3f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -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