Terraform Modules Template Project

pre-commit latest release Renovate enabled semantic-release

Submit a new module

👍🎉 Thank you for taking the time to contribute! 🎉👍

This template repository exists to help you create Terraform modules for IBM Cloud.

The default structure includes the following files:

  • README.md: A description of the module
  • main.tf: The logic for the module
  • version.tf: The required terraform and provider versions
  • variables.tf: The input variables for the module
  • outputs.tf: The values that are output from the module For more information, see Module structure in the project documentation.

You can add other content to support what your module does and how it works. For example, you might add a scripts/ directory that contains shell scripts that are run by a local-exec null_resource in the Terraform module.

Follow this process to create and submit a Terraform module.

Create a repo from this repo template

  1. Create a repository from this repository template by clicking Use this template in the upper right of the GitHub UI.     
    For more information about creating a repository from a template, see the GitHub docs.
  2. Select terraform-ibm-modules as the owner.
  3. Enter a name for the module in format terraform-ibm-<NAME>, where <NAME> reflects the type of infrastructure that the module manages.     
    Use hyphens as delimiters for names with multiple words (for example, terraform-ibm-activity-tracker).
  4. Provide a short description of the module.     
    The description is displayed under the repository name on the organization page and in the About section of the repository. Use the description to help users understand the purpose of your module. For more information, see module names and descriptions in the docs.

Clone the repo and set up your development environment

Locally clone the new repository and set up your development environment by completing the tasks in Local development setup in the project documentation.

Update the repo name and description in source control

To help make sure that the repo name and description are not changed except through pull requests, they are defined in the settings.yml file.

Check to make sure that values are uncommented and correct:

  1. Open the settings.yml file.
  2. If not already updated, uncomment the name and description properties and set the values to what you specified when you requested the repo.

Update the Terraform files

Implement the logic for your module by updating the main.tf, version.tf, variables.tf, and outputs.tf Terraform files. For more information, see Creating Terraform on IBM Cloud templates.

Create examples and tests

Add one or more examples in the examples directory that consume your new module, and configure tests for them in the tests directory. For more information about tests, see Tests.

Update the content in the readme file

After you implement the logic for your module and create examples and tests, update this readme file in your repository by following these steps:

  1. Update the title heading and add a description about your module.
  2. Update the badge links.
  3. Remove all the content in this H2 heading section.
  4. Complete the Usage and Required IAM access policies sections. The Examples and Requirements section are populated by a pre-commit hook.

Commit your code and submit your module for review

  1. Before you commit any code, review Contributing to the IBM Cloud Terraform modules project in the project documentation.
  2. Create a pull request for review.

Post-merge steps

After the first PR for your module is merged, follow these post-merge steps:

  1. Create a PR to enable the upgrade test by removing the t.Skip line in tests/pr_test.go.

Usage

Required IAM access policies

Examples

Requirements

Name Version
terraform >= 1.0.0, <1.6.0

Modules

No modules.

Resources

No resources.

Inputs

No inputs.

Outputs

No outputs.

Contributing

You can report issues and request features for this module in GitHub issues in the module repo. See Report an issue or request a feature.

To set up your local development environment, see Local development setup in the project documentation.