Skip to content

Instantly share code, notes, and snippets.

@mAster-rAdio
Created April 3, 2019 05:25
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mAster-rAdio/0749d320a3dffefad4df5629224cd808 to your computer and use it in GitHub Desktop.
Save mAster-rAdio/0749d320a3dffefad4df5629224cd808 to your computer and use it in GitHub Desktop.
Terraformでファイル単位でtarget指定するためのワンライナー

Terraformでファイル単位でtarget指定するためのワンライナー

plan

terraform plan `cat hoge.tf | terraform fmt - | grep -E 'resource |module ' | tr -d '"' | awk '{printf("-target=%s.%s ",$2,$3);}'`

apply

terraform appy `cat hoge.tf | terraform fmt - | grep -E 'resource |module ' | tr -d '"' | awk '{printf("-target=%s.%s ",$2,$3);}'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment