Skip to content

Commit

Permalink
docs: adds README files for modules
Browse files Browse the repository at this point in the history
  • Loading branch information
nimisha-gj committed Jul 9, 2024
1 parent 9cc0033 commit 68f4e31
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 123 deletions.
3 changes: 0 additions & 3 deletions .header.md
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
# Main

asdfadsfas
22 changes: 3 additions & 19 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
formatter: "" # this is required

version: ""
formatter: "markdown table"

header-from: .header.md
footer-from: ""
Expand All @@ -10,25 +8,11 @@ recursive:
path: modules
include-main: true

sections:
hide: []
show: []

hide-all: false # deprecated in v0.13.0, removed in v0.15.0
show-all: true # deprecated in v0.13.0, removed in v0.15.0

content: ""

output:
file: ""
mode: inject
file: "README.md"
mode: replace
template: |-
{{ .Content }}
\n
output-values:
enabled: false
from: ""
sort:
enabled: true
Expand Down
125 changes: 25 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,113 +1,38 @@
# Terraform Module Template

This repository serves as a template for creating Terraform modules. It provides a structured approach to organizing and maintaining Terraform code, along with examples and best practices.

## Table of Contents
## Requirements

- [Prerequisites](#prerequisites)
- [Usage](#usage)
- [Examples](#examples)
- [Module Structure](#module-structure)
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.4.6 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.65.0 |

## Prerequisites
## Providers

Before you begin, ensure you have met the following requirements:
No providers.

1. [install terraform](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)
2. [install pre-commit](https://pre-commit.com/#install)
3. configure pre-commit: `pre-commit install`
4. install required tools
- [tflint](https://github.com/terraform-linters/tflint)
- [terraform-docs](https://github.com/terraform-docs/terraform-docs)
## Modules

## Usage
| Name | Source | Version |
|------|--------|---------|
| <a name="module_dynamodb_tf_state_lock"></a> [dynamodb\_tf\_state\_lock](#module\_dynamodb\_tf\_state\_lock) | ./modules/dynamodb_table | n/a |
| <a name="module_tf_state_s3_bucket"></a> [tf\_state\_s3\_bucket](#module\_tf\_state\_s3\_bucket) | ./modules/s3 | n/a |

To use this template, clone the repository and customize it according to your module's requirements. Below is a quick start guide:
## Resources

1. **Clone the repository:**
No resources.

```sh
git clone https://github.com/your-username/terraform-module-template.git
cd terraform-module-template
```
2. **Customize the module:**
## Inputs

- Update `main.tf`, `variables.tf`, `outputs.tf`, and `versions.tf` files as needed.
- Add your own resources and logic.
3. **Run Terraform commands:**
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_dynamodb_read_capacity"></a> [dynamodb\_read\_capacity](#input\_dynamodb\_read\_capacity) | (Optional) Number of read units for this table. | `number` | `20` | no |
| <a name="input_dynamodb_table_name"></a> [dynamodb\_table\_name](#input\_dynamodb\_table\_name) | (Required) Unique Table name within a region name of the table | `string` | n/a | yes |
| <a name="input_dynamodb_table_tags"></a> [dynamodb\_table\_tags](#input\_dynamodb\_table\_tags) | (Optional) A map of tags to populate on the created table. | `map(string)` | `{}` | no |
| <a name="input_dynamodb_write_capacity"></a> [dynamodb\_write\_capacity](#input\_dynamodb\_write\_capacity) | (Optional) Number of write units for this table. | `number` | `20` | no |
| <a name="input_s3_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | Name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | n/a | yes |
| <a name="input_s3_bucket_tags"></a> [s3\_bucket\_tags](#input\_s3\_bucket\_tags) | (Optional) Map of tags to assign to the bucket. | `map(string)` | `{}` | no |

```sh
terraform init
terraform plan
terraform apply
```
## Outputs

## Examples

This repository includes example configurations to help you understand how to use the module:

- **Complete Example:** Located in `examples/complete`

- Demonstrates a full-featured usage of the module.

```sh
cd examples/complete
terraform init
terraform apply
```
- **Minimal Example:** Located in `examples/minimal`

- Shows a minimal configuration for using the module.

```sh
cd examples/minimal
terraform init
terraform apply
```

## Module Structure

The repository is organized as follows:

```plaintext
.
├── .editorconfig
├── examples
│ ├── complete
│ │ ├── main.tf
│ │ ├── outputs.tf
│ │ ├── provider.tf
│ │ ├── README.md
│ │ ├── variables.tf
│ │ └── versions.tf
│ └── minimal
│ ├── main.tf
│ ├── outputs.tf
│ ├── provider.tf
│ ├── README.md
│ ├── variables.tf
│ └── versions.tf
├── .github
│ └── workflows
│ ├── documentation.yaml
│ ├── pre-commit.yaml
│ └── pr-title.yaml
├── .gitignore
├── main.tf
├── modules
│ └── sample-resource
│ ├── main.tf
│ ├── outputs.tf
│ ├── variables.tf
│ └── version.tf
├── outputs.tf
├── .pre-commit-config.yaml
├── README.md
├── .terraform-docs.yml
├── tests
│ ├── examples_minimal.tftest.hcl
│ └── unit_tests.tftest.hcl
├── .tflint.hcl
├── variables.tf
└── versions.tf
```
No outputs.
Empty file.
32 changes: 32 additions & 0 deletions modules/dynamodb_table/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_dynamodb_table.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/dynamodb_table) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | (Required) Unique Table name within a region name of the table | `string` | n/a | yes |
| <a name="input_read_capacity"></a> [read\_capacity](#input\_read\_capacity) | (Optional) Number of read units for this table. | `number` | `20` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) A map of tags to populate on the created table. | `map(string)` | `{}` | no |
| <a name="input_write_capacity"></a> [write\_capacity](#input\_write\_capacity) | (Optional) Number of write units for this table. | `number` | `20` | no |

## Outputs

No outputs.
1 change: 0 additions & 1 deletion modules/dynamodb_table/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ variable "tags" {
type = map(string)
default = {}
}

Empty file added modules/s3/.header.md
Empty file.
30 changes: 30 additions & 0 deletions modules/s3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.57.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_name"></a> [name](#input\_name) | Name of the bucket. If omitted, Terraform will assign a random, unique name. | `string` | n/a | yes |
| <a name="input_tags"></a> [tags](#input\_tags) | (Optional) Map of tags to assign to the bucket. | `map(string)` | `{}` | no |

## Outputs

No outputs.

0 comments on commit 68f4e31

Please sign in to comment.