diff --git a/.github/.workflows/terraform_docs.yml b/.github/.workflows/terraform_docs.yml new file mode 100644 index 0000000..2ec2082 --- /dev/null +++ b/.github/.workflows/terraform_docs.yml @@ -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" \ No newline at end of file diff --git a/.terraform-docs.yml b/.terraform-docs.yml new file mode 100644 index 0000000..f46384b --- /dev/null +++ b/.terraform-docs.yml @@ -0,0 +1,4 @@ +formatter: "markdown" +version: "0.16.0" +output: + file: README.md diff --git a/GNUmakefile b/GNUmakefile index f7da4aa..7d9abd6 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -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 + diff --git a/README.md b/README.md index 79aa4c5..5335b75 100644 --- a/README.md +++ b/README.md @@ -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. - + ## Requirements | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.14 | -| [aws](#requirement\_aws) | >= 3.0, < 5.0.0 | +| [aws](#requirement\_aws) | >= 3.0 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.0, < 5.0.0 | +| [aws](#provider\_aws) | >= 3.0 | + +## Modules + +No modules. ## Resources @@ -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 | +| [aws\_resources\_prefix](#input\_aws\_resources\_prefix) | Prefix to use for created AWS resources | `string` | `""` | no | +| [aws\_resources\_tags](#input\_aws\_resources\_tags) | A map/dictionary of Tags to be assigned to created AWS resources | `map(string)` | `{}` | no | +| [lacework\_access\_token](#input\_lacework\_access\_token) | The access token for the Lacework agent | `string` | `""` | no | +| [lacework\_agent\_build\_hash](#input\_lacework\_agent\_build\_hash) | An Agent build hash provided by Lacework | `string` | `""` | no | +| [lacework\_agent\_tags](#input\_lacework\_agent\_tags) | A map/dictionary of Tags to be assigned to the Lacework datacollector | `map(string)` | `{}` | no | +| [lacework\_agent\_temp\_path](#input\_lacework\_agent\_temp\_path) | The temporary path for the Lacework installation script | `string` | `"/tmp"` | no | +| [lacework\_enable\_default\_syscall\_config](#input\_lacework\_enable\_default\_syscall\_config) | A flag to enable the default syscall config | `string` | `"false"` | no | +| [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 | +| [ssm\_document\_name](#output\_ssm\_document\_name) | Name of the AWS SSM Document that setups the Lacework agent | + diff --git a/scripts/terraform-docs.sh b/scripts/terraform-docs.sh new file mode 100755 index 0000000..96e4f65 --- /dev/null +++ b/scripts/terraform-docs.sh @@ -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 \ No newline at end of file