Terraform 㧠State ãåå²ããã¨ãããããã® root module ãã§ãã¾ãã ãã root module ãå¥ module ã® remote state åç §ãæã¤ã¨ããmodule éã«ä¾åé¢ä¿ãçãã¾ãã åãã¡ã¯ãã®ä¾åé ã« terraform ã apply ããªããã°ãªãã¾ãããããã®éé ã« destroy ãã¦ãããªãã¨ãããªãã
æåã§ãããè¨æ¶ããã®ã大å¤ã ããæãã«ãªã£ã¦ããã®ã§ã©ããããã®ããªã¨æã£ãæã«æã£ãç°¡åãªè§£æ±ºçã¯ããã®ä¾åé ãããã¹ããã¡ã¤ã«ã§è¡¨ç¾ãã¦ããã¨ãããã®ã§ããã
$ cat dependency.dat module1 module2 module3
ä¸è¨ã®ããã«ä¾åé ããã®ã¾ã¾æ¸ãä¸ãã dependency.dat
ãç¨æãã¦ããã¦ã xargs
ã«é£ãããã
$ cat dependency.dat | xargs -I% sh -c 'echo === % ===; cd %; terraform apply -auto-approve'
destroy ããã¨ãã¯éé ã§ã®é©ç¨ãå¿
è¦ã§ãããæã
ã«ã¯ tac
ã³ãã³ããããã
$ tac dependency.dat | xargs -I% sh -c 'echo === % ===; cd %; terraform destroy -auto-approve'