Skip to content

Commit

Permalink
[bug] fixing logic for cleaning up old tf.json files (airbnb#949)
Browse files Browse the repository at this point in the history
* Update getting-started.rst

Warning that newer versions of Terraform are not supported.

* Update getting-started.rst

removed that weird trailing space

* Update athena-overview.rst

Removing deprecated --table-type arg

* Update generate.py

Set the correct extension for TF state files.

* removing old note

* fixing old change
  • Loading branch information
geremyCohen authored and ryandeivert committed Jun 19, 2019
1 parent bd35056 commit 02ea192
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions stream_alert_cli/terraform/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,14 @@ def generate_cluster(config, cluster_name):

def cleanup_old_tf_files(config):
"""Cleanup old .tf files, these are now .tf.json files per Hashicorp best practices"""
files_for_removal = set(config.clusters()).union({'athena', 'main'})
for terraform_file in os.listdir('terraform'):
if terraform_file == 'variables.tf':
continue

if fnmatch(terraform_file, '*.tf'):
if fnmatch(terraform_file, '*.tf.json'):
# Allow to retain misc files in the terraform/ directory
if terraform_file.split('.')[0] in config.clusters() + ['athena', 'main']:
if terraform_file.split('.')[0] in files_for_removal:
os.remove(os.path.join('terraform', terraform_file))


Expand Down

0 comments on commit 02ea192

Please sign in to comment.