diff --git a/.github/workflows/terraform_docs.yml b/.github/workflows/terraform_docs.yml
new file mode 100644
index 0000000..276d534
--- /dev/null
+++ b/.github/workflows/terraform_docs.yml
@@ -0,0 +1,29 @@
+name: Test that terraform docs has been run
+on: push
+jobs:
+ docs:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ ref: ${{ github.event.pull_request.head.ref }}
+ - name: Install terraform-docs
+ run: curl -L https://github.com/terraform-docs/terraform-docs/releases/download/v0.16.0/terraform-docs-v0.16.0-linux-amd64.tar.gz | (cd /usr/local/bin; tar zxvf -; chmod +x /usr/local/bin/terraform-docs)
+ - name: store hash of orig README.md
+ id: old_hash
+ run: echo "README_HASH=$(md5sum README.md)" >> $GITHUB_OUTPUT
+ - name: Update README.md using terraform-docs make target
+ run: make terraform-docs
+ - name: store hash of new README.md
+ id: new_hash
+ run: echo "README_HASH=$(md5sum README.md)" >> $GITHUB_OUTPUT
+ - name: echo hashes
+ run: |
+ echo ${{ steps.old_hash.outputs.README_HASH }}
+ echo ${{ steps.new_hash.outputs.README_HASH }}
+ - name: test to see of hashs are the same
+ if: ${{ steps.old_hash.outputs.README_HASH != steps.new_hash.outputs.README_HASH }}
+ uses: actions/github-script@v6
+ with:
+ script: |
+ core.setFailed('Please run "make terraform-docs" and try again')
\ 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 e5154a6..80e3cad 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -5,3 +5,8 @@ ci:
release: ci
scripts/release.sh prepare
+
+.PHONY: terraform-docs
+terraform-docs:
+ scripts/terraform-docs.sh
+
diff --git a/README.md b/README.md
index 1fb1ee7..913dab1 100644
--- a/README.md
+++ b/README.md
@@ -30,18 +30,19 @@ The terraform module will create the following in your AWS account
## Prequisites
[Install the Lacework CLI](https://docs.lacework.com/cli#installation), [create an API Key](https://docs.lacework.com/cli#create-api-key) and [configure the CLI with the API key](https://docs.lacework.com/cli#configure-the-cli). [Install the AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) and configure a profile.
+
## Requirements
| Name | Version |
|------|---------|
-| [aws](#requirement\_aws) | ~> 3.0 |
+| [aws](#requirement\_aws) | >= 3.0 |
| [lacework](#requirement\_lacework) | ~> 1.0 |
## Providers
| Name | Version |
|------|---------|
-| [aws](#provider\_aws) | ~> 3.0 |
+| [aws](#provider\_aws) | >= 3.0 |
| [lacework](#provider\_lacework) | ~> 1.0 |
## Modules
@@ -62,9 +63,9 @@ No modules.
| [aws_lambda_event_source_mapping.lacework-alerts-sqs-to-lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource |
| [aws_lambda_function.lacework_sqs_to_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_s3_bucket.lacework_alerts_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource |
-| [aws_s3_bucket_public_access_block.alerts_bucket_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
-| [aws_s3_bucket_ownership_controls.alerts_bucket_ownership_controls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
| [aws_s3_bucket_acl.example](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_acl) | resource |
+| [aws_s3_bucket_ownership_controls.alerts_bucket_ownership_controls](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_ownership_controls) | resource |
+| [aws_s3_bucket_public_access_block.alerts_bucket_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource |
| [aws_sqs_queue.lacework_alerts_queue](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue) | resource |
| [aws_sqs_queue_policy.lacework_alerts_queue_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sqs_queue_policy) | resource |
| [lacework_alert_channel_aws_cloudwatch.all_events](https://registry.terraform.io/providers/lacework/lacework/latest/docs/resources/alert_channel_aws_cloudwatch) | resource |
@@ -84,6 +85,7 @@ No modules.
## Outputs
No outputs.
+
## Manual install
diff --git a/scripts/release_helpers.sh b/scripts/release_helpers.sh
index d9a8235..3106297 100644
--- a/scripts/release_helpers.sh
+++ b/scripts/release_helpers.sh
@@ -1,6 +1,6 @@
#
# Name:: release_helpers.sh
-# Description:: A set of helper funtions to be used by our release.sh script
+# Description:: A set of helper functions to be used by our release.sh script
# Author:: Salim Afiune Maya ()
#
@@ -137,6 +137,7 @@ prepare_release() {
prerequisites
remove_tag_version
check_for_minor_version_bump
+ generate_readme
generate_release_notes
update_changelog
push_release
@@ -192,6 +193,10 @@ generate_release_notes() {
echo "$(cat CHANGES.md)" >> RELEASE_NOTES.md
}
+generate_readme() {
+ make terraform-docs
+}
+
load_list_of_changes() {
latest_version=$(find_latest_version)
local _list_of_changes=$(git log --no-merges --pretty="* %s (%an)([%h](https://github.com/${org_name}/${project_name}/commit/%H))" ${latest_version}..${main_branch})
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