Search code examples
aws-ebs-csi-driver

How to reuse dynamically provisioned EBS volumes with AWS EBS CSI driver after recreating EKS cluster?


Is there a way to reuse the EBS volumes, that are dynamically provisioned by the AWS EBS CSI driver, after destroying and recreating the EKS cluster? It is not possible to set a static value for the CSIVolumeName tag. So, is there any other way?


Solution

  • No, there is not a direct way due to the reason mentioned in the comment. But there is a solution to this. Solution: Create a Lambda, that uses AWS SDK to fetch the required dynamically provisioned EBS volumes, that are to be reused, and creates PersistentVolumes with claimRef using the tags present in the fetched EBS volumes. In this way, the claimRef will have the name of the previously created PersistentVolumeClaim as its value. And when the PersistentVolumeClaims are recreated after EKS cluster recreation, this Lambda gets executed, the PersistentVolumes get created, the PersistentVolumeClaims are automatically mapped to those PersistentVolumes with their names in the claimRef.