How to Auto-attach a Terraform module to an Ephemeral Environment

Introduction

Ephemeral environments are environments meant to be used for a limited amount of time, and then discarded.

You can automatically create ephemeral environments with a pull request, with a pull request comment, or via API integration with your current CI/CD solution.

How to automatically create Ephemeral Environments

  • Select your environment in the Bunnyshell interface.

  • Click the Settings button. The settings for the selected environment are displayed.

  • In the Ephemeral environments section, toggle on the Create ephemeral environments on pull request option. This option is automatically saved by Bunnyshell.

How to Auto-attach a Terraform module

Bunnyshell can automatically clone a Terraform module associated with the main environment and attach it to the ephemeral environment.

You can activate this feature when you attach the module to an environment. Simply set the Auto-attach to Ephemeral Environments switch to ON when selecting the module you want to attach.

Alternatively, you can follow these steps to activate it:

  • Select the environment where the module is attached.

  • Select Terraform modules.

  • The modules attached to that particular environment are now displayed. Click the Options button corresponding to your environment and select Edit.

  • Set the Auto-attach to Ephemeral Environments switch to ON

Cloning Variables

When an ephemeral environment is automatically created and the Terraform module is applied, the variables need to have unique names.

This is why we implemented an extra feature, where we have a set of possible values that help you grant unique IDs to your configurable variables:

${BNS_ENVIRONMENT_UNIQUE}

${BNS_ENVIRONMENT_NAME}

All of these help you automatically inject a unique ID in the value of your variable whenever an ephemeral environment is automatically created.

Last updated

Was this helpful?