diff --git a/terrabutler/click.py b/terrabutler/click.py index d421899..8eaebe0 100755 --- a/terrabutler/click.py +++ b/terrabutler/click.py @@ -121,10 +121,12 @@ def env_new_cli(name, y, t, a, s3): @env_cli.command(name="select", help="Select a environment") @click.argument('NAME') +@click.option("-init", default=True, + help="Disable auto init of the sites") @click.option("-s3", is_flag=True, help="Access S3 instead of parsing terraform output") -def env_select_cli(name, s3): - set_current_env(name, s3) +def env_select_cli(name, init, s3): + set_current_env(name, s3, init=init) @env_cli.command(name="show", help="Show the name of the current environment") diff --git a/terrabutler/env.py b/terrabutler/env.py index a301962..6c92a65 100644 --- a/terrabutler/env.py +++ b/terrabutler/env.py @@ -95,7 +95,7 @@ def get_current_env(): return f.read() -def set_current_env(env, s3): +def set_current_env(env, s3, init=False): current_env = get_current_env() available_envs = get_available_envs(s3) @@ -117,7 +117,8 @@ def set_current_env(env, s3): exit(1) reload_direnv() - terraform_init_all_sites() + if init: + terraform_init_all_sites() print("\n\n" + Fore.GREEN + f"Switched to environment '{env}'.") diff --git a/terrabutler/tf.py b/terrabutler/tf.py index cab0fc0..ed948ee 100644 --- a/terrabutler/tf.py +++ b/terrabutler/tf.py @@ -138,4 +138,5 @@ def terraform_init_all_sites(): sites.remove("inception") for site in sites: print(Fore.YELLOW + f"Initializing {site} site") - terraform_command_runner("init", ["-reconfigure"], "backend", site) + terraform_command_runner("init", site, options=["-reconfigure"], + needed_options="backend")