|
2 | 2 |
|
3 | 3 | [](https://travis-ci.com/cytopia/docker-terraform-docs)
|
4 | 4 | [](https://github.com/cytopia/docker-terraform-docs/releases)
|
5 |
| -[](https://microbadger.com/images/cytopia/terraform-docs "terraform-docs") |
6 |
| -[](https://microbadger.com/images/cytopia/terraform-docs "terraform-docs") |
| 5 | +[](https://microbadger.com/images/cytopia/terraform-docs:latest "terraform-docs") |
| 6 | +[](https://microbadger.com/images/cytopia/terraform-docs:latest "terraform-docs") |
7 | 7 | [](https://opensource.org/licenses/MIT)
|
8 | 8 |
|
9 | 9 |
|
10 | 10 | [](https://hub.docker.com/r/cytopia/terraform-docs)
|
11 | 11 |
|
| 12 | + |
12 | 13 | ## Official project
|
13 | 14 |
|
14 | 15 | https://github.com/segmentio/terraform-docs
|
15 | 16 |
|
16 | 17 |
|
| 18 | +## Available Docker image versions |
| 19 | + |
| 20 | +| Docker tag | Build from | |
| 21 | +|------------|------------| |
| 22 | +| `latest` | [Branch: master](https://github.com/segmentio/terraform-docs) | |
| 23 | +| `0.6.0` | [Tag: v0.6.0](https://github.com/segmentio/terraform-docs/tree/v0.6.0) | |
| 24 | +| `0.5.0` | [Tag: v0.5.0](https://github.com/segmentio/terraform-docs/tree/v0.5.0) | |
| 25 | +| `0.4.5` | [Tag: v0.4.5](https://github.com/segmentio/terraform-docs/tree/v0.4.5) | |
| 26 | +| `0.4.0` | [Tag: v0.4.0](https://github.com/segmentio/terraform-docs/tree/v0.4.0) | |
| 27 | +| `0.3.0` | [Tag: v0.3.0](https://github.com/segmentio/terraform-docs/tree/v0.3.0) | |
| 28 | +| `0.2.0` | [Tag: v0.2.0](https://github.com/segmentio/terraform-docs/tree/v0.2.0) | |
| 29 | +| `0.1.1` | [Tag: v0.1.1](https://github.com/segmentio/terraform-docs/tree/v0.1.1) | |
| 30 | +| `0.1.0` | [Tag: v0.1.0](https://github.com/segmentio/terraform-docs/tree/v0.1.0) | |
| 31 | + |
| 32 | + |
| 33 | +## Docker mounts |
| 34 | + |
| 35 | +The working directory inside the Docker container is `/docs/` and should be mounted locally to |
| 36 | +where your Terraform module is located. |
| 37 | + |
| 38 | + |
| 39 | +## Usage |
| 40 | + |
| 41 | +#### Output to stdout |
| 42 | +Create markdown output and sent to stdout: |
| 43 | +```bash |
| 44 | +docker run --rm \ |
| 45 | + -v $(pwd):/docs \ |
| 46 | + --sort-inputs-by-required --with-aggregate-type-defaults md . |
| 47 | +``` |
| 48 | + |
| 49 | +#### Store in file |
| 50 | +Create README.md with `terraform-docs` output: |
| 51 | +```bash |
| 52 | +docker run --rm \ |
| 53 | + -v $(pwd):/docs \ |
| 54 | + --sort-inputs-by-required --with-aggregate-type-defaults md . > README.md |
| 55 | +``` |
| 56 | + |
| 57 | +#### Replace in README.md |
| 58 | +Replace current `terraform-docs` blocks in README.md with current one in order to automatically |
| 59 | +keep it up to date. For this to work, the `terraform-docs` information must be wrapped with the |
| 60 | +following delimiter: |
| 61 | +```markdown |
| 62 | +<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 63 | +## Inputs |
| 64 | +... |
| 65 | +<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
| 66 | +``` |
| 67 | + |
| 68 | +```bash |
| 69 | +# Save output in variable |
| 70 | +DOCS="$( |
| 71 | + docker run --rm \ |
| 72 | + -v $(pwd):/docs \ |
| 73 | + --sort-inputs-by-required --with-aggregate-type-defaults md . |
| 74 | +)" |
| 75 | + |
| 76 | +# Create new README |
| 77 | +grep -B 100000000 -F '<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->' README.md > README.md.tmp |
| 78 | +printf "${DOCS}\n\n" >> README.md.tmp |
| 79 | +grep -A 100000000 -F '<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->' README.md >> README.md.tmp |
| 80 | + |
| 81 | +# Overwrite old README |
| 82 | +mv -f README.md.tmp README.md |
| 83 | +``` |
| 84 | + |
| 85 | + |
| 86 | +## Example projects |
| 87 | + |
| 88 | +Find below some example projects how this Docker image is used in CI to verify if the README.md has |
| 89 | +been updated with the latest changes generated from `terraform-docs`: |
| 90 | + |
| 91 | +* https://github.com/cytopia/terraform-aws-rds/blob/master/Makefile |
| 92 | + |
| 93 | + |
17 | 94 | ## License
|
18 | 95 |
|
19 | 96 | **[MIT License](LICENSE)**
|
|
0 commit comments