Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run terraform init before running terraform show #2734

Merged
merged 2 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/_nebari/provider/terraform.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ def tfimport(addr, id, directory=None, var_files=None, exist_ok=False):
raise e


def show(directory=None) -> dict:
def show(directory=None, terraform_init: bool = True) -> dict:

if terraform_init:
init(directory)

logger.info(f"terraform show directory={directory}")
command = ["show", "-json"]
with timer(logger, "terraform show"):
Expand Down
6 changes: 5 additions & 1 deletion src/_nebari/stages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,15 @@ def set_outputs(

@contextlib.contextmanager
def deploy(
self, stage_outputs: Dict[str, Dict[str, Any]], disable_prompt: bool = False
self,
stage_outputs: Dict[str, Dict[str, Any]],
disable_prompt: bool = False,
terraform_init: bool = True,
):
deploy_config = dict(
directory=str(self.output_directory / self.stage_prefix),
input_vars=self.input_vars(stage_outputs),
terraform_init=terraform_init,
)
state_imports = self.state_imports()
if state_imports:
Expand Down
4 changes: 3 additions & 1 deletion src/_nebari/stages/terraform_state/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ def deploy(
):
self.check_immutable_fields()

with super().deploy(stage_outputs, disable_prompt):
# No need to run terraform init here as it's being called when running the
# terraform show command, inside check_immutable_fields
with super().deploy(stage_outputs, disable_prompt, terraform_init=False):
env_mapping = {}
# DigitalOcean terraform remote state using Spaces Bucket
# assumes aws credentials thus we set them to match spaces credentials
Expand Down
Loading