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