Skip to main content

terraform/tfa

1#!/usr/bin/env bash
2# This is an alias for "terraform apply".
4# == Handle refresh-only changes ==
5#
6# If Terraform doesn't want to make any changes, it will give you
7# a message:
8#
9# Your configuration already matches the changes detected above.
10# If you'd like to update the Terraform state to match, create and
11# apply a refresh-only plan:
12# terraform apply -refresh-only
14# At this point it's tempting to run `tfa -refresh-only`, but that needs
15# to be handled separately. If you pass it through the branch below,
16# you get an error:
18# Error: Too many command line arguments
19# Expected at most one positional argument.
21# because under the hood it's running:
23# terraform apply terraform.plan -refresh-only
25# which doesn't make any sense!
27if [[ "$@" == "-refresh-only" ]]
28then
29 tf apply -refresh-only
31# All other Terraform operations
32else
33 tf apply tfplan "$@"
34fi