0

In autoscaling group, I have an EC2 instance (with two EBS storage) which could terminate due to any fault and a new EC2 instance is spun in it's place inside the autoscaling group. My question is how the two EBS storage attached to old EC2 instance be attached to new EC2 instance. if this is manual process, could reference to terraform be provided.

ruakn
  • 188
  • 1
  • 9
  • @rukan I guess you need to make 'DeleteOnTermination' value as false, as you would need EBS of old instances for newly created one. Reference : https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_Ebs.html – Tapan Hegde Mar 14 '22 at 12:56
  • yeah, if we make deleteontermination as false, don't we have to attach the ebs to newly started EC2? – ruakn Mar 16 '22 at 07:50
  • @rukan Hi, I guess it is not possible and not recommended one. Probably you can use EFS instead of EBS, but keep a eye on latency caused by EFS. I have updated my answer with details – Tapan Hegde Mar 16 '22 at 09:31

1 Answers1

0

@rukan I guess you need to make 'DeleteOnTermination' value as false, as you would need EBS of old instances for newly created one.

Reference :

https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_Ebs.html

https://francescoboffa.com/aws-stateful-service-ebs/

Update :

I tried to do some research on your requirement and I can conclude my answer that there is no standard method where we can re-use EBS volume in AWS auto-scaling group. Moreover It is not recommended one, as autoscaling groups start multiple EC2 instances. Each EBS volume can only be attached to a single EC2 instance. For now, I can suggest to use AWS EFS instead of EBS.

But, if this is must do requirement with EBS, then we need think of some complex logic where writing some kind of startup script which associated the volume with the EC2 instance then mounted it. You can refer this answer

Reference :

https://serverfault.com/questions/831974/can-i-re-use-an-ebs-volume-with-aws-asg

Tapan Hegde
  • 1,222
  • 1
  • 8
  • 25