Skip to content

Commit

Permalink
rebuilding pkg on every tf run
Browse files Browse the repository at this point in the history
  • Loading branch information
ryandeivert committed Jul 6, 2020
1 parent ca63116 commit d0e8312
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion streamalert_cli/manage_lambda/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def deploy(config, functions, clusters=None):
LOGGER.debug('Applying terraform targets: %s', ', '.join(sorted(deploy_targets)))

# Terraform applies the new package and publishes a new version
return terraform_runner(config, targets=deploy_targets, build_pkg=True)
return terraform_runner(config, targets=deploy_targets)


def _update_rule_table(options, config):
Expand Down
8 changes: 1 addition & 7 deletions streamalert_cli/terraform/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,7 @@ def handler(cls, options, config):
if not valid:
return False

build_pkg = any('lambda' in target for target in target_modules)

return terraform_runner(
config,
targets=target_modules if target_modules else None,
build_pkg=build_pkg,
)
return terraform_runner(config, targets=target_modules if target_modules else None)


class TerraformDestroyCommand(CLICommand):
Expand Down
21 changes: 7 additions & 14 deletions streamalert_cli/terraform/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@
LOGGER = get_logger(__name__)


def terraform_runner(
config,
refresh=True,
auto_approve=False,
targets=None,
destroy=False,
build_pkg=False):
def terraform_runner(config, refresh=True, auto_approve=False, targets=None, destroy=False):
"""Terraform wrapper to build StreamAlert infrastructure.
Resolves modules with `terraform get` before continuing.
Expand Down Expand Up @@ -66,13 +60,12 @@ def terraform_runner(
if targets:
tf_command.extend('-target={}'.format(x) for x in targets)

# Building of the deployment package should happen if Lambda is
# an explict target or there are no targets at all
if build_pkg or not targets:
deployment_package = package.LambdaPackage(config)
package_path = deployment_package.create()
if not package_path:
return False
# Build the deployment package so the Lambda does not produce an error
# TODO: maybe remove this as packacking improvements progress
deployment_package = package.LambdaPackage(config)
package_path = deployment_package.create()
if not package_path:
return False

return run_command(tf_command, cwd=config.build_directory)

Expand Down

0 comments on commit d0e8312

Please sign in to comment.