【terraform】一部のリソースだけapply,deleteする(-target)
-targetオプションでリソースを指定することで可能
code:コマンド実行時
$ terraform destroy -target=aws_instance.test
apply,destroy,mainで使えそうなのは確認。
ただ冪等性が失われるため注意すること。
以下のような警告が出た。
code:コマンド実行時
│ Warning: Resource targeting is in effect
│
│ You are creating a plan with the -target option, which means that the result of this plan may not represent all of the
│ changes requested by the current configuration.
│
│ The -target option is not for routine use, and is provided only for exceptional situations such as recovering from
│ errors or mistakes, or when Terraform specifically suggests to use it as part of an error message.
参考
terraform