terraform test - outputs from your module
To test terraform module, you can place your module into folder, let's call module.
In your test that you place in the root directory, you can have the following:
Then run terraform init and terraform test to execute your tests. As shown in the diagram above, you need to declare output from your module - and in this case we have our output called resource_group_name. All we need to do is, use the output keyword and append whatever variable we have just output.
The output full code.
You should see the final test results as shown here. A thing to note about running terraform test is that it will run test on the root folder and then look for a directory call tests.
You can still test it to use a different folder by specifying --test-directory options. Now terraform will go to the specified directory say for example, abc folder, then root folder and finally tests folder.
Code to the repo
https://github.com/mitzenjeremywoo?tab=repositories
Comments