-
-
Save maliciousgroup/559c0d5ca12f943a3d0afc978c66ffa7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from python_terraform import * | |
def create_resources(template: str, variables: dict) -> str: | |
count = 0 | |
while count < 10: | |
tf = Terraform() | |
tf.init(template) | |
_, stdout, stderr = tf.apply( | |
template, | |
capture_output=True, | |
no_color=IsFlagged, | |
skip_plan=True, | |
state=f"{template.split('/')[-1]}.tfstate", | |
var=variables) | |
if stdout: | |
return stdout | |
elif stderr: | |
count += 1 | |
continue | |
return stderr | |
def destroy_resources(template: str, variables: dict) -> str: | |
count = 0 | |
while count < 10: | |
tf = Terraform() | |
_, stdout, stderr = tf.destroy( | |
template, | |
capture_output=False, | |
no_color=IsFlagged, | |
state=f"{template.split('/')[-1]}.tfstate", | |
var=variables) | |
if stdout: | |
return stdout | |
elif stderr: | |
count += 1 | |
continue | |
return stderr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment