Skip to content

oaknational/oak-terraform-modules

Repository files navigation

Oak Terraform Modules

Modules

Developing with modules

Developing a module is slightly trickier than just writing straight Terraform. Here are some tips to help you ease the process.

Keeping it local

When writing a module you will need some code to call that module and test if it works. Far and away the easiest way to do this is create a subdirectory for your module, put all your module config in there, call it from the main Terraform config and finally copy all that config to this repo when it is working.

module "example" {
  source = "./module"

  ...
}

Double dots

If the workspace is processed locally i.e. not in Terraform Cloud, you can have this repo checked out locally and link to it within the module using a relative or full path.

Note. This will not work if the workspace is processed in Terraform Cloud as TFC cannot resolve the path.

module "example" {
  source = "../../oak-terraform-modules/modules/example"

  ...
}

Pointing to a different branch

It is possible to work from this repo, although this is a slower process.

  1. Point the module to your new branch
  2. Push your changes to Github
  3. Update Terraform terraform init -upgrade
  4. Repeat from 2. until it works

Note. If the branch name has a / in it you need to replace that with the URL encoded equivalent: %2F

module "example" {
  source = "github.com/oaknational/oak-terraform-modules//modules/example?ref=feat%2Fexample"

  ...
}

Release Workflow

Once code is merged and you are ready to release,

  • git checkout main -> git pull
  • git tag vx.x.x
  • git push origin vx.x.x -In the repo, click Releases → Draft a new release.
  • In choose a tag , select the tag you just pushed (e.g vx.x.x)
  • Fill in the title and release notes
  • Click Publish release.

About

Some Terraform modules that follow Oak naming etc standards

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors