Hello all,
i have a little problem with my terraform execution, i use the 0.11 version, and i want to import an existing aws infrastrure.
Many of my resources have already been imported, but when i import aws_security_group, terraform absolutely want to remove aws_security_group… I think he cannot import the rules, so i change my method for create resource :
Before :
resource “aws_security_group” “WinRM” {
name = “toto-terraform.workspace-WinRM”
vpc id = “${aws_vpc.toto.id}”
tags {
Environment = “terraform.workspace”
Name =“toto-terraform.workspace-winrm”
}
lifecycle {
ignore_changes = [“name”,“description”]
}
}
ingress {
from_port = 5986
to_port = 5986
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
lifecycle {
ignore_changes = [“name”,“description”]
}
}
And after :
resource “aws_security_group” “WinRM” {
name = “toto-terraform.workspace-WinRM”
vpc_id = “aws_vpc.toto.id”
tags {
Environment = “terraform.workspace”
Name =“toto-terraform.workspace-winrm”
}
lifecycle {
ignore_changes = [“name”,“description”]
}
}
resource “aws_security_group_rule” “WinRM” {
type = “ingress”
from_port = 5986
to_port = 5986
protocol = “tcp”
cidr_blocks = [“0.0.0.0/0”]
security_group_id = “aws_security_group.WinRM.id”
}
unfortunately, when i import SG and SG rules, and i run terrafom plan, terraform want destroy “aws_security_group_rule.WinRM-1”
Any advice ?
Thank you !