How to use check_terraform_version method in localstack

Best Python code snippet using localstack_python

test_terraform.py

Source:test_terraform.py Github

copy

Full Screen

...15LAMBDA_HANDLER = "DotNetCore2::DotNetCore2.Lambda.Function::SimpleFunctionHandler"16LAMBDA_RUNTIME = "dotnetcore2.0"17LAMBDA_ROLE = "arn:aws:iam::000000000000:role/iam_for_lambda"18INIT_LOCK = threading.RLock()19def check_terraform_version():20 if not is_command_available("terraform"):21 return False, None22 ver_string = run("terraform -version")23 ver_string = re.search(r"v(\d+\.\d+\.\d+)", ver_string).group(1)24 if ver_string is None:25 return False, None26 return version.parse(ver_string) < version.parse("0.15"), ver_string27class TestTerraform(unittest.TestCase):28 @classmethod29 def setUpClass(cls):30 available, version = check_terraform_version()31 if not available:32 msg = "could not find a compatible version of terraform"33 if version:34 msg += f" (version = {version})"35 else:36 msg += " (command not found)"37 return pytest.skip(msg)38 with INIT_LOCK:39 run("cd %s; terraform apply -input=false tfplan" % (cls.get_base_dir()))40 @classmethod41 def tearDownClass(cls):42 run("cd %s; terraform destroy -auto-approve" % (cls.get_base_dir()))43 @classmethod44 def init_async(cls):45 available, ver_string = check_terraform_version()46 if not available:47 print(48 "Skipping Terraform test init as version check failed (version: '%s')" % ver_string49 )50 return51 def _run(*args):52 with INIT_LOCK:53 base_dir = cls.get_base_dir()54 if not os.path.exists(os.path.join(base_dir, ".terraform", "plugins")):55 run("cd %s; terraform init -input=false" % base_dir)56 # remove any cache files from previous runs57 for tf_file in [58 "tfplan",59 "terraform.tfstate",...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful