Question
How to not destroy my opensearch domain when performing 'terraform destroy'?
I have created many different AWS resources with terraform such as ECS, VPC, EC2, opensearch... I'm in a debugging phase and I need to frequently create/destroy dozens of resources besides opensearch (I don't want to destroy opensearch because it's very slow to create/delete)
I used "terraform state rm " to remove opensearch from state management, but it associated a security group:
resource "aws_security_group" "opensearch" {
name = "${terraform.workspace}-opensearch"
vpc_id = local.vpc_id
}
I used "terraform state rm " again to remove this sg from state, but after that when I run terraform apply
, terraform still seems to be trying to create this sg:
Error: creating Security Group (default-opensearch): InvalidGroup.Duplicate: The security group 'default-opensearch' already exists for VPC 'xxxxx'