Terraform v0.12.7
following the example found in the docs: https://www.terraform.io/docs/providers/aws/r/lightsail_static_ip_attachment.html
for creating a lightsail static IP attachment.
when I update the configuration of the aws_lightsail_instance changing the bundle_id or any other attribute that requires destroy/add new instance, I'm expecting that the aws_lightsail_static_ip_attachment would still work (and be re-attached to the new lightsail instance`
I get the static IP detached from the old destroyed instance, but not attached to the new instance.
resource "aws_lightsail_static_ip_attachment" "test" {
static_ip_name = "${aws_lightsail_static_ip.test.name}"
instance_name = "${aws_lightsail_instance.test.name}"
}
resource "aws_lightsail_static_ip" "test" {
name = "example"
}
resource "aws_lightsail_instance" "test" {
name = "example"
availability_zone = "eu-central-1a"
blueprint_id = "centos_7_1901_01" # or any other valid blueprint
bundle_id = "nano_2_0" # or any other valid bundle
}
terraform applymicro_2_0 (or any other valid option to make the instance destroy and recreate)terraform applyIt will work if you do terraform apply again. The name of the instance doesn't change so it's hard to plan the change.
thanks, it does work after a second terraform apply, but isn't there a way to make the 2 resources aware of each other?
Well, there's a ticket for that, even comment specifically for that: https://github.com/hashicorp/terraform/issues/8099#issuecomment-494121768
However now that I took a second look at it shouldn't you just use id instead of name? It's the same value but id is generated.
Awesome, thanks a lot... using the ID instead of the name actually solved the problem...
Should it be mentioned in the documentation/example somehow (as I was following it)?
I have a PR open for updating the documentation of lightsail ip attachment #10141
I could add a footnote or somthing about this.
Well, updating the documentation is probably a great idea and if you won't make the PR I will when I have some time to test it.
Most helpful comment
Well, there's a ticket for that, even comment specifically for that: https://github.com/hashicorp/terraform/issues/8099#issuecomment-494121768
However now that I took a second look at it shouldn't you just use id instead of name? It's the same value but id is generated.