Terraform Modules in Bunnyshell

Terraform Modules in Bunnyshell are templates which can be used to create cloud-managed services (dependencies) for your application environments.

They provide governance, as you can only have the permission to modify certain input variables when attaching to an Environment ("lock" the instance size, for example, to limit costs).

Furthermore, they abstract all the configuration needed for a Terraform module and allow only relevant options to be configured.

A Terraform Module can be attached to any number of Environments.

1. To create Terraform Modules in Bunnyshell, click the Terraform Module icon on the left side of the interface.

2. Click on Add Terraform module.

3. Fill in the name and description.

4. Select the repository, branch and path of the module

In this case, we used the repository demo-books-terraform and the branch master in order to test out a module that hasn't been released yet.

The path should be set to /backend/_terraform as this is the folder in which the Terraform module is defined for the application.

In general, you should use a permanent branch when you define your final modules.

5. The module will now be validated

6. Needed variables will be detected. In our case, we only have the bucket name, which needs to be defined. Click Define value.

7. Fill in the necessary fields as indicated below.

  • Type: Fixed value (String, Number, Bool)

  • Value: books-{{ env.unique }}

8. Next, environment variables need to be added (env vars with which Terraform will run). These are not related to Bunnyshell Environments. Click Add variable, as indicated below.

9. It's time to add the values required for cloud access:

AWS_ACCESS_KEY_ID = replace-access-key

AWS_SECRET_ACCESS_KEY = replace-secret

AWS_REGION = us-west-1

You can choose the access key to be a secret, allowing it to be obfuscated.

10. The plan will now be tested with the provided values.

11. Finally, the output values are detected. They will be used after attaching the Module to an Environment.

You can also choose to exclude irrelevant output values, in order not to pollute the variable namespace - not the case here.

12. Click Add Terraform Module. And that's it: you have a Module which you can use in your Environments.

Last updated

Was this helpful?