Skip to content

This is a Starter kit to help with the creation of Terraform modules

License

Notifications You must be signed in to change notification settings

edeavila4000/terraform-ibm-module-template

 
 

Repository files navigation

IBM Cloud <module_name> - Terraform Module

Mention the purpose of writing these modules.

E.g:

This is a collection of modules that make it easier to provision and configure Observability services like logging, monitor and activity tracker on IBM Cloud Platform:

Compatibility

This module is meant for use with Terraform 0.13 (and higher).

Usage

Examples are captured in examples folder, demonstarte how to use a module through a template:

e.g:

provider "ibm" {
}

data "ibm_resource_group" "logdna" {
  name = var.resource_group
}

module "logdna_instance" {
  source  = "terraform-ibm-modules/observability/ibm//modules/logging-logdna"


  bind_resource_key   = var.bind_resource_key
  service_name        = var.service_name
  resource_group_id   = data.ibm_resource_group.logdna.id
  plan                = var.plan
  region              = var.region
  service_endpoints   = var.service_endpoints
  tags                = var.tags
  resource_key_name   = var.resource_key_name
  role                = var.role
  resource_key_tags   = var.resource_key_tags
}

Requirements

Terraform plugins

Install

Terraform

Be sure you have the correct Terraform version (0.13), you can choose the binary here:

Terraform plugins

Be sure you have the compiled plugins on $HOME/.terraform.d/plugins/

Pre-commit hooks

Run the following command to execute the pre-commit hooks defined in .pre-commit-config.yaml file

pre-commit run -a

You can install pre-coomit tool using

pip install pre-commit

or

pip3 install pre-commit

Detect Secret hook

Used to detect secrets within a code base.

To create a secret baseline file run following command

detect-secrets scan --update .secrets.baseline

While running the pre-commit hook, if you encounter an error like

WARNING: You are running an outdated version of detect-secrets.
Your version: 0.13.1+ibm.27.dss
Latest version: 0.13.1+ibm.46.dss
See upgrade guide at https://ibm.biz/detect-secrets-how-to-upgrade

run below command

pre-commit autoupdate

which upgrades all the pre-commit hooks present in .pre-commit.yaml file.

How to input variable values through a file

To review the plan for the configuration defined (no resources actually provisioned)

terraform plan -var-file=./input.tfvars

To execute and start building the configuration defined in the plan (provisions resources)

terraform apply -var-file=./input.tfvars

To destroy the VPC and all related resources

terraform destroy -var-file=./input.tfvars

Note

All optional parameters, by default, will be set to null in respective example's variable.tf file. You can also override these optional parameters.

About

This is a Starter kit to help with the creation of Terraform modules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HCL 94.0%
  • Go 6.0%