Hi
TL;DR
If
a configuration file contains an aws_instance, aws_ebs_volum and
aws_volume_attachment, is there any way to terminate the instance and
the volume, then importing a new instance and (an already attached) volume,
and still prevent terraform from creating a new aws_ebs_attachment?
Longer version:I
am creating a small service for setting up and maintaining a cluster of
ec2-instances, and i am using terraform for creating and updating the
aws components.
To put things simply: a user can specify the number
of instances and the type for each instance, and the volume size
(ebs-backed). Note that each instance has a unique role, so i cant just
specify (for example) count=3 in the config file, therefore each
instance is named uniquely (fro example instance1, instance2 and
instance3).
now lets assume, that instance3 has died, and should be replaced.
I want to be able to:
1. manually create a new instance,
2. manually attach it to a new ebs volume
3. manually install my very important software
4. import the new instance and ebs volume to my state file as instance4.
5. Verify programmatically that terraform isnt going to create or destroy anything.
the
problem is that terraform insists on recreating the
aws_ebs_attachement, even though the instance and the volume are already
attached.
is there any way to let terraform "know" that the instance and the volume are already attached?
thanks