Open syphernl opened 2 years ago
I run into this issue...
The workaround I'm using:
# Most of the time the server is off, this manually added data-resource
# avoids the need to constantly switch between on and off config.
data "aws_instance" "test_instance" {
instance_id = "${the_instance_id}"
}
module "test_instance" {
source = "cloudposse/ec2-instance/aws"
version = "x.x.x"
...
...
associate_public_ip_address = data.aws_instance.test_instance.instance_state == "running" ? true : false
...
...
}
This isn't pretty, but at least I can continue to run terraform regardless of the state of the VM.
Hope this helps! Joel.
Describe the Bug
Creating an instance using this module with the following flags:
causes the instance to be recreated when it is
stopped
because the "public address" (not EIP) is released when the server is shutdown.To prevent this from happening we could add a lifecycle configuration which ignores this particular key. Unfortunately this cannot be done on a
module
object within Terraform so it must be done from inside the module itself.Expected Behavior
No instance re-creation.
Steps to Reproduce
Steps to reproduce the behavior:
plan
and see that it will be recreated