in solutions_builder/cli/infra.py [0:0]
def terraform_apply(solution_path, stage, unlock=False,
yes=False, impersonate_email=None, project_id=None):
# Get auto-approve flag.
auto_approve_flag = "-auto-approve" if yes else ""
# Get impersonate service account email
env_var_clause = get_impersonate_clause(
project_id, impersonate_email) if impersonate_email else ""
# Get unlock flag
unclock_clause = " -lock=false" if unlock else ""
# Init and apply in a specific stage folder.
print(f"Applying Terraform stage: '{stage}'...")
working_dir = f"{solution_path}/terraform/stages/{stage}"
exec_shell(f"{env_var_clause} terraform init {unclock_clause}",
working_dir=working_dir)
exec_shell(f"{env_var_clause} terraform apply {auto_approve_flag} {unclock_clause}",
working_dir=working_dir)
exec_shell(f"{env_var_clause} terraform output > tf_output.tfvars",
working_dir=working_dir)