I have created two Terraform modules, each creating a simple AWS instance and then provisioning some software on it with an Ansible playbook. Each module works correctly when running terraform apply in the module directory.
How would you combine these two modules in a shell script to create both instances, run some tests and then destroy the ressources.
In my mind the shell script would be like this :
terraform apply --reference=module1-dir --state=module1-state
terraform apply --reference=module2-dir --state=module2-state
<run some other scripts ...>
terraform destroy --reference=module1-dir --state=module1-state
terraform destroy --reference=module2-dir --state=module2-state
Is this the correct way to do it ? Does Terraform support referencing another directory to fetch the files to run ?