Demonstration of Module

Auto Module Generation

Module: projectA

locals projectA:locals

Project Locals

Definition of locals projectA:locals from file locals.tf
 2locals {
 3  full_bucket_name = "${var.environment}-${var.bucket_name}"
 4
 5  common_tags = merge(
 6    {
 7      Environment = var.environment
 8      Owner       = var.owner
 9      ManagedBy   = "terraform"
10    },
11    var.tags
12  )
13}
variable bucket_name
Definition of variable bucket_name from file main.tf
28variable "bucket_name" {
29  type        = string
30  description = "The base name for the S3 bucket. A suffix will be appended to ensure global uniqueness."
31}
variable environment
Definition of variable environment from file main.tf
33variable "environment" {
34  type        = string
35  description = "Deployment environment (e.g. dev, staging, production)."
36  default     = "dev"
37}
variable owner
Definition of variable owner from file main.tf
39variable "owner" {
40  type        = string
41  description = "Team or individual responsible for this bucket."
42  default     = "unset"
43}
variable tags
Definition of variable tags from file main.tf
51variable "tags" {
52  type        = map(string)
53  description = "Additional tags to apply to all resources."
54  default     = {}
55}
variable versioning_enabled
Definition of variable versioning_enabled from file main.tf
45variable "versioning_enabled" {
46  type        = bool
47  description = "Enable S3 object versioning on the bucket."
48  default     = false
49}
terraform projectA:terraform
Definition of terraform projectA:terraform from file main.tf
18terraform {
19  required_version = ">= 1.3.0"
20  required_providers {
21    aws = {
22      source  = "hashicorp/aws"
23      version = ">= 4.0"
24    }
25  }
26}
resource aws_s3_bucket main

Primary storage bucket for project assets.

Definition of resource aws_s3_bucket main from file s3.tf
2resource "aws_s3_bucket" "main" {
3  bucket = local.full_bucket_name
4  tags   = local.common_tags
5}
resource aws_s3_bucket_public_access_block main

Block all public access by default.

Definition of resource aws_s3_bucket_public_access_block main from file s3.tf
32resource "aws_s3_bucket_public_access_block" "main" {
33  bucket = aws_s3_bucket.main.id
34
35  block_public_acls       = true
36  block_public_policy     = true
37  ignore_public_acls      = true
38  restrict_public_buckets = true
39}
resource aws_s3_bucket_server_side_encryption_configuration main
Definition of resource aws_s3_bucket_server_side_encryption_configuration main from file s3.tf
21resource "aws_s3_bucket_server_side_encryption_configuration" "main" {
22  bucket = aws_s3_bucket.main.id
23
24  rule {
25    apply_server_side_encryption_by_default {
26      sse_algorithm = "AES256"
27    }
28  }
29}
resource aws_s3_bucket_versioning main

Another Pre Comment

Definition of resource aws_s3_bucket_versioning main from file s3.tf
 9resource "aws_s3_bucket_versioning" "main" {
10  bucket = aws_s3_bucket.main.id
11
12  versioning_configuration {
13    status = var.versioning_enabled ? "Enabled" : "Suspended"
14  }
15}

Module: projectB

resource foo_resource baz

Here is a resource.

… code-block:: shell

rm -rf /somepath

look out :tf:data:foo_data.qux

Definition of resource foo_resource baz from file main.tf
37resource "foo_resource" "baz" {
38}
resource foo_resource markdown

Here is documentation in Markdown (MyST).

Use it like so:

Also, an hyperlink.

Definition of resource foo_resource markdown from file main.tf
48resource "foo_resource" "markdown" {
49}
data foo_data qux

Documentation for this data.

Might be somewhat related to :tf:resource:foo_resource.baz.

Definition of data foo_data qux from file main.tf
54data "foo_data" "qux" {
55}
terraform projectB:terraform

Documentation for terraform/main.tf

  • list item 1

  • list item 2

Even inline formatting in here is possible. and some link inline link , Internal Link.

Definition of terraform projectB:terraform from file main.tf
10terraform {
11  required_version = ">= 0.12"
12  required_providers {
13    foo = {
14      source  = "https://registry.acme.com/foo"
15      version = ">= 1.0"
16    }
17  }
18}
module foobar
Definition of module foobar from file main.tf
20module "foobar" {
21  source = "git@github.com:module/path?ref=v7.8.9"
22}
module sub
Definition of module sub from file main.tf
24module "sub" {
25
26}
variable submodule-input

A very nice input variable in submodule

Definition of variable submodule-input from file sub/variables.tf
2variable "submodule-input" {
3}
variable some-variable

A very nice input variable

Definition of variable some-variable from file variables.tf
2variable "some-variable" {
3}

CLI Tools

TFReport

Generate a Terraform documentation report for a module path.

usage: tfreport [-h] [--level LEVEL] [-v] path

Positional Arguments

path

Path to the Terraform module directory.

Named Arguments

--level

Heading level for the generated report (default: 1).

Default: 1

-v, --verbose

Verbosity Controls

Default: []

TFMap

Expand the Terraform Map

usage: tfmapexpand [-h] [-v] map

Positional Arguments

map

Map of Terraform Modules yaml file

Named Arguments

-v, --verbose

Verbosity Controls

Default: []