Skip to content

Commit 1fabadf

Browse files
committed
Fix the docs and hook
1 parent 2c6557f commit 1fabadf

File tree

7 files changed

+225
-25
lines changed

7 files changed

+225
-25
lines changed

.githooks/pre-commit

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
set -euo pipefail
1313

14+
script_dir=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
15+
16+
tf_modules=$("$script_dir/../scripts/collect-modules.sh")
17+
1418
function command_exists() {
1519
bin_name=$(basename "$1")
1620

@@ -25,21 +29,17 @@ function command_exists() {
2529

2630
files=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
2731

28-
if [[ -z "$files" ]]; then
29-
echo "No files changed. Exiting the pre-commit hook..."
30-
exit 0
31-
fi
32-
3332
if command_exists typos; then
3433
echo "$files" | xargs typos
3534
fi
3635

3736
if command_exists terraform-docs; then
38-
pushd asset-account/terraform/stack-set
39-
files="$files asset-account/terraform/stack-set/README.md"
37+
for tf_module in $tf_modules; do
38+
terraform-docs markdown "$tf_module" --output-file "README.md"
4039

41-
terraform-docs markdown . --output-file README.md
42-
popd
40+
# Extend `$files` to make `prettier` format the generated README.md
41+
files="$files $tf_module/README.md"
42+
done
4343
fi
4444

4545
if command_exists ./node_modules/.bin/prettier; then

.github/actions/collect-modules/action.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,6 @@ runs:
1313
- name: Find modules
1414
id: find-modules
1515
run: |
16-
set -eu
17-
18-
tf_modules=()
19-
for module_cfg in $(find . -name .module.toml); do
20-
case $(yq -o y .module.type $module_cfg) in
21-
null)
22-
echo "Warning: module type not found in $module_cfg"
23-
continue
24-
;;
25-
terraform)
26-
echo "Found Terraform module in $module_cfg"
27-
tf_modules+=($(dirname $module_cfg))
28-
;;
29-
esac
30-
done
31-
16+
tf_modules=$(./scripts/collect-modules.sh)
3217
echo tf-modules=$(printf '%s\n' "${tf_modules[@]}" | jq -cnR '[inputs]') > $GITHUB_OUTPUT
3318
shell: bash

connector/terraform/README.md

Lines changed: 55 additions & 0 deletions
Large diffs are not rendered by default.

connector/terraform/modules/account/README.md

Lines changed: 58 additions & 0 deletions
Large diffs are not rendered by default.

connector/terraform/modules/nat-provision/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,41 @@ module "elastio_nat_provision" {
1616
// Provide input parameters
1717
}
1818
```
19+
20+
<!-- BEGIN_TF_DOCS -->
21+
22+
## Requirements
23+
24+
| Name | Version |
25+
| ------------------------------------------------------------------------ | ------- |
26+
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | ~> 1.0 |
27+
| <a name="requirement_aws"></a> [aws](#requirement_aws) | ~> 5.0 |
28+
29+
## Providers
30+
31+
| Name | Version |
32+
| ------------------------------------------------ | ------- |
33+
| <a name="provider_aws"></a> [aws](#provider_aws) | ~> 5.0 |
34+
35+
## Modules
36+
37+
No modules.
38+
39+
## Resources
40+
41+
| Name | Type |
42+
| --------------------------------------------------------------------------------------------------------------------------------- | -------- |
43+
| [aws_cloudformation_stack.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudformation_stack) | resource |
44+
45+
## Inputs
46+
47+
| Name | Description | Type | Default | Required |
48+
| ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | ------- | :------: |
49+
| <a name="input_connector_account_stack"></a> [connector_account_stack](#input_connector_account_stack) | The Elastio Connector Account stack metadata. This is used to inherit the<br/> configs by the `nat-provision` stack. The value for this parameter can be<br/> provided as the `cloudformation_stack` output of the `account` module, or<br/> you could use a `data "aws_cloudformation_stack"` data source to fetch the<br/> stack metadata and provide it here. | <pre>object({<br/> parameters = map(string)<br/> })</pre> | n/a | yes |
50+
| <a name="input_template_version"></a> [template_version](#input_template_version) | Specifies the version of Elastio NAT provision stack to deploy (e.g. `v5`).<br/><br/> This is a Cloudformation stack that automatically provisions NAT Gateways in<br/> your VPC when Elastio worker instances run to provide them with the outbound<br/> Internet access when Elastio is deployed in private subnets.<br/><br/> If you don't need this stack (e.g. you already have NAT gateways in your VPC<br/> or you deploy into public subnets) you can omit this parameter. The default<br/> value of `null` means there won't be any NAT provision stack deployed.<br/><br/> The source code of this stack can be found here:<br/> https://github.com/elastio/contrib/tree/master/elastio-nat-provision-lambda | `string` | `"v5"` | no |
51+
52+
## Outputs
53+
54+
No outputs.
55+
56+
<!-- END_TF_DOCS -->

connector/terraform/modules/region/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,48 @@ module "elastio_connector_region" {
1616
// Provide input parameters
1717
}
1818
```
19+
20+
<!-- BEGIN_TF_DOCS -->
21+
22+
## Requirements
23+
24+
| Name | Version |
25+
| ------------------------------------------------------------------------ | ------- |
26+
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | ~> 1.0 |
27+
| <a name="requirement_aws"></a> [aws](#requirement_aws) | ~> 5.0 |
28+
29+
## Providers
30+
31+
| Name | Version |
32+
| ------------------------------------------------------------------ | ------- |
33+
| <a name="provider_aws"></a> [aws](#provider_aws) | ~> 5.0 |
34+
| <a name="provider_terraform"></a> [terraform](#provider_terraform) | n/a |
35+
36+
## Modules
37+
38+
No modules.
39+
40+
## Resources
41+
42+
| Name | Type |
43+
| -------------------------------------------------------------------------------------------------------------------------------- | ----------- |
44+
| [terraform_data.elastio_cloud_connector](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
45+
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
46+
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
47+
48+
## Inputs
49+
50+
| Name | Description | Type | Default | Required |
51+
| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ------- | :------: |
52+
| <a name="input_connector_account_stack"></a> [connector_account_stack](#input_connector_account_stack) | The Elastio Connector Account stack metadata. This is used to inherit the<br/> configs by the `region` stack. The value for this parameter can be<br/> provided as the `cloudformation_stack` output of the `account` module, or<br/> you could use a `data "aws_cloudformation_stack"` data source to fetch the<br/> stack metadata and provide it here. | <pre>object({<br/> name = string<br/> parameters = map(string)<br/> })</pre> | n/a | yes |
53+
| <a name="input_elastio_pat"></a> [elastio_pat](#input_elastio_pat) | Personal Access Token generated by the Elastio Portal | `string` | n/a | yes |
54+
| <a name="input_elastio_tenant"></a> [elastio_tenant](#input_elastio_tenant) | Name of your Elastio tenant. For example `mycompany.app.elastio.com` | `string` | n/a | yes |
55+
| <a name="input_region"></a> [region](#input_region) | The AWS region where the Elastio connector will be deployed. If not specified<br/> then the currently configured default region will be used. | `string` | `null` | no |
56+
| <a name="input_subnet_ids"></a> [subnet_ids](#input_subnet_ids) | The IDs of the subnets where the Elastio connector will be deployed<br/><br/> Must be omitted if the `network_configuration` was set to `Auto` in the `account` module,<br/> in which case Elastio will automatically create a VPC and subnets. | `list(string)` | `null` | no |
57+
| <a name="input_vpc_id"></a> [vpc_id](#input_vpc_id) | The ID of the VPC where the Elastio connector will be deployed.<br/><br/> Must be omitted if the `network_configuration` was set to `Auto` in the `account` module,<br/> in which case Elastio will automatically create a VPC and subnets. | `string` | `null` | no |
58+
59+
## Outputs
60+
61+
No outputs.
62+
63+
<!-- END_TF_DOCS -->

scripts/collect-modules.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
tf_modules=()
6+
while IFS= read -r -d '' module_cfg; do
7+
case $(yq -o y .module.type "$module_cfg") in
8+
null)
9+
echo "Warning: module type not found in $module_cfg" >&2
10+
exit 1
11+
;;
12+
terraform)
13+
echo "Found Terraform module in $module_cfg" >&2
14+
tf_modules+=("$(dirname "$module_cfg")")
15+
;;
16+
esac
17+
done < <(find . -name .module.toml -print0)
18+
19+
printf '%s\n' "${tf_modules[@]}"

0 commit comments

Comments
 (0)