Skip to content

Commit

Permalink
fix for init backend outside of generate logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandeivert committed Jul 2, 2020
1 parent 14f11f9 commit 21ad641
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
4 changes: 4 additions & 0 deletions streamalert_cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def tf_runner(config, action='apply', refresh=True, auto_approve=False, targets=
Returns:
bool: True if the terraform command was successful
"""
LOGGER.info('Initializing StreamAlert')
if not run_command(['terraform', 'init'], cwd=config.terraform_temp_path):
return False

LOGGER.debug('Resolving Terraform modules')
if not run_command(['terraform', 'get'], cwd=config.terraform_temp_path, quiet=True):
return False
Expand Down
15 changes: 1 addition & 14 deletions streamalert_cli/terraform/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from streamalert.shared.logger import get_logger
from streamalert.shared.utils import get_database_name, get_data_file_format
from streamalert_cli.athena.helpers import generate_alerts_table_schema
from streamalert_cli.helpers import check_credentials, run_command
from streamalert_cli.helpers import check_credentials
from streamalert_cli.terraform import TERRAFORM_FILES_PATH
from streamalert_cli.terraform.common import (
InvalidClusterName,
Expand Down Expand Up @@ -386,16 +386,6 @@ def handler(cls, options, config):
return terraform_generate_handler(config, check_creds=False)


def _terraform_init_backend(config):
"""Initialize the infrastructure backend (S3) using Terraform
Returns:
bool: False if errors occurred, True otherwise
"""
LOGGER.info('Initializing StreamAlert backend')
return run_command(['terraform', 'init'], cwd=config.terraform_temp_path)


def _copy_terraform_files(config):
"""Copy all packaged terraform files and terraform files provided by the user to temp
Expand Down Expand Up @@ -459,9 +449,6 @@ def terraform_generate_handler(config, init=False, check_tf=True, check_creds=Tr
if init:
return True

if not _terraform_init_backend(config):
return False

# Setup cluster files
for cluster in config.clusters():
if cluster in RESTRICTED_CLUSTER_NAMES:
Expand Down

0 comments on commit 21ad641

Please sign in to comment.