Skip to content

Commit

Permalink
docs(readme): add terraform docs automation
Browse files Browse the repository at this point in the history
Add terraform docs script along with makefile target and gihub action for same

Signed-off-by: Timothy MacDonald <tim.macdonald@lacework.net>
  • Loading branch information
tmac1973 committed Oct 5, 2023
1 parent 2294ccc commit 7df8079
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 12 deletions.
18 changes: 18 additions & 0 deletions .github/.workflows/terraform_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Generate terraform docs
on:
- pull_request
jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}

- name: Render terraform docs inside the README.md and push changes back to PR branch
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: .
output-file: README.md
output-method: inject
git-push: "true"
4 changes: 4 additions & 0 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
formatter: "markdown"
version: "0.16.0"
output:
file: README.md
5 changes: 5 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,8 @@ ci: ## *CI ONLY* Runs tests on CI pipeline
.PHONY: release
release: ci ## *CI ONLY* Prepares a release of the Terraform module
scripts/release.sh prepare

.PHONY: terraform-docs
terraform-docs:
scripts/terraform-docs.sh

29 changes: 17 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@
[![Codefresh build status]( https://g.codefresh.io/api/badges/pipeline/lacework/terraform-modules%2Ftest-compatibility?type=cf-1&key=eyJhbGciOiJIUzI1NiJ9.NWVmNTAxOGU4Y2FjOGQzYTkxYjg3ZDEx.RJ3DEzWmBXrJX7m38iExJ_ntGv4_Ip8VTa-an8gBwBo)]( https://g.codefresh.io/pipelines/edit/new/builds?id=607e25e6728f5a6fba30431b&pipeline=test-compatibility&projects=terraform-modules&projectId=607db54b728f5a5f8930405d)

A Terraform Module to create an AWS Systems Manager document for installing the Lacework Datacollector Agent on to AWS EC2 instances.

<!-- BEGIN_TF_DOCS -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0, < 5.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.0 |

## Providers

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

## Modules

No modules.

## Resources

Expand All @@ -30,17 +34,18 @@ A Terraform Module to create an AWS Systems Manager document for installing the

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| aws_resources_prefix | Prefix to use for created AWS resources | `string` | `""` | no |
| aws_resources_tags | A map/dictionary of Tags to be assigned to created AWS resources | `map(string)` | `{}` | no |
| lacework_access_token | The access token for the Lacework agent | `string` | `""` | no |
| lacework_agent_build_hash | An Agent build hash provided by Lacework | `string` | `""` | no |
| lacework_agent_tags | A map/dictionary of Tags to be assigned to the Lacework datacollector | `map(string)` | `{}` | no |
| lacework_agent_temp_path | The temporary path for the Lacework installation script | `string` | `"/tmp"` | no |
| lacework_server_url | The server URL for the Lacework agent | `string` | `""` | no |
| lacework_enable_default_syscall_config | A flag to enable the default syscall config | `string` | `"false"` | no |
| <a name="input_aws_resources_prefix"></a> [aws\_resources\_prefix](#input\_aws\_resources\_prefix) | Prefix to use for created AWS resources | `string` | `""` | no |
| <a name="input_aws_resources_tags"></a> [aws\_resources\_tags](#input\_aws\_resources\_tags) | A map/dictionary of Tags to be assigned to created AWS resources | `map(string)` | `{}` | no |
| <a name="input_lacework_access_token"></a> [lacework\_access\_token](#input\_lacework\_access\_token) | The access token for the Lacework agent | `string` | `""` | no |
| <a name="input_lacework_agent_build_hash"></a> [lacework\_agent\_build\_hash](#input\_lacework\_agent\_build\_hash) | An Agent build hash provided by Lacework | `string` | `""` | no |
| <a name="input_lacework_agent_tags"></a> [lacework\_agent\_tags](#input\_lacework\_agent\_tags) | A map/dictionary of Tags to be assigned to the Lacework datacollector | `map(string)` | `{}` | no |
| <a name="input_lacework_agent_temp_path"></a> [lacework\_agent\_temp\_path](#input\_lacework\_agent\_temp\_path) | The temporary path for the Lacework installation script | `string` | `"/tmp"` | no |
| <a name="input_lacework_enable_default_syscall_config"></a> [lacework\_enable\_default\_syscall\_config](#input\_lacework\_enable\_default\_syscall\_config) | A flag to enable the default syscall config | `string` | `"false"` | no |
| <a name="input_lacework_server_url"></a> [lacework\_server\_url](#input\_lacework\_server\_url) | The server URL for the Lacework agent | `string` | `""` | no |

## Outputs

| Name | Description |
|------|-------------|
| ssm_document_name | Name of the AWS SSM Document that setups the Lacework agent |
| <a name="output_ssm_document_name"></a> [ssm\_document\_name](#output\_ssm\_document\_name) | Name of the AWS SSM Document that setups the Lacework agent |
<!-- END_TF_DOCS -->
13 changes: 13 additions & 0 deletions scripts/terraform-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

if which terraform-docs >/dev/null; then
terraform-docs .
elif which docker >/dev/null; then
echo "## terraform-docs not found in PATH, but docker was found"
echo "## running terraform-docs in docker"
terraform_docs_version=$(cat .terraform-docs.yml | grep version | cut -d\" -f 2)
docker run --rm -v `pwd`:/data cytopia/terraform-docs:${terraform_docs_version} terraform-docs .
else
echo "## terraform-docs not found in PATH, neither was docker"
echo "## please install terraform-docs or docker"
exit 1
fi

0 comments on commit 7df8079

Please sign in to comment.