You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. Output the plan to text file: write all resources changing to text file
terraform plan -no-color > tfplan.txt
4. Force unlock state: Acquire state lock from another process
terraform force-unlock <LockID>
5. Output the resources to graph
terraform graph | dot -Tsvg -o tfgraph.svg
6. Untracking resource state:
terraform state rm <ResouceState>
7. Destroy specific resource:
terraform destroy -target=<ResouceState>
8. Refresh state with manual change
tfa -refresh-only
9. Pull state from remote to local
tf state pull > resources.tfstate
10. Multiple target script
get_target() {
# $1: pattern of target resource you want to filter(based on your terraform files), e.g: aws_subnet
# $2: prefix that you want to add to -target, e.g: module.test.
# result: -target module.test.aws_subnet.subnet_name
pattern=$1
prefix=$2
apply_targets=""
for target in $(grep -hRe "^resource.*$pattern" | sed -e 's/resource "//g' | sed 's/" {//g' | sed 's/" "/./g'); do apply_targets="$apply_targets -target $prefix$target"; done
}
get_target "aws_subnet" "module.test." | xargs -r terraform apply -auto-approve