Skip to content

Commit

Permalink
Add DocGen and Gen'd Docs (#25)
Browse files Browse the repository at this point in the history
* add doc-gen script

* docgen

* update readme to point at docs
  • Loading branch information
erindatkinson authored Oct 30, 2019
1 parent fa393b3 commit 09b6416
Show file tree
Hide file tree
Showing 14 changed files with 244 additions and 55 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
work/
71 changes: 71 additions & 0 deletions .scripts/doc-gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash

set -e

BINARY_DIR=./work
BINARY_FILE="${BINARY_DIR}/terraform-docs"
BINARY_VERSION=0.6.0
BINARY_URL_PREFIX="https://github.com/segmentio/terraform-docs/releases/download/v${BINARY_VERSION}/terraform-docs-v${BINARY_VERSION}"

DOCS_CMDS="--sort-inputs-by-required --with-aggregate-type-defaults markdown table"
DOCS_DIR=docs

VARS_TF=variables.tf
OUTS_TF=outputs.tf

INS_MD=inputs.md
OUTS_MD=outputs.md


function setup {
mkdir -p ${BINARY_DIR}
if [[ ! -e "${BINARY_FILE}" ]]; then
if [[ "$OSTYPE" == "linux-gnu" ]]; then
BINARY_URL="${BINARY_URL_PREFIX}-linux-amd64"
elif [[ "$OSTYPE" == "darwin"* ]]; then
BINARY_URL="${BINARY_URL_PREFIX}-darwin-amd64"
else
echo "Please run this in either a Linux or Mac environment."
exit 1
fi
echo "Downloading ${BINARY_URL}"
curl -L -o "${BINARY_FILE}" "${BINARY_URL}"
chmod +x "${BINARY_FILE}"
fi
}

function main_docs {
if test ! -d "${DOCS_DIR}"; then
mkdir "${DOCS_DIR}"
fi

echo -e "# Terraform Enterprise: Clustering\n" | tee "${DOCS_DIR}/${INS_MD}" "${DOCS_DIR}/${OUTS_MD}" &> /dev/null

eval "${BINARY_FILE} ${DOCS_CMDS} ${VARS_TF}" >> "${DOCS_DIR}/${INS_MD}"
eval "${BINARY_FILE} ${DOCS_CMDS} ${OUTS_TF}" >> "${DOCS_DIR}/${OUTS_MD}"

}


function module_docs {
if test -d ./modules; then
for dir in ./modules/*; do
mkdir -p "${dir}/${DOCS_DIR}"

echo -e "# Terraform Enterprise: Clustering\n" | tee "${dir}/${DOCS_DIR}/${INS_MD}" "${dir}/${DOCS_DIR}/${OUTS_MD}" &> /dev/null

eval "${BINARY_FILE} ${DOCS_CMDS} ${dir}/${VARS_TF}" >> "${dir}/${DOCS_DIR}/${INS_MD}"
eval "${BINARY_FILE} ${DOCS_CMDS} ${dir}/${OUTS_TF}" >> "${dir}/${DOCS_DIR}/${OUTS_MD}"
done
else
echo "No modules directory, skipping."
fi
}


setup
main_docs
module_docs



3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: docs
docs:
.scripts/doc-gen.sh
65 changes: 10 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,68 +10,23 @@ The Replicated license used must have been activated for Terraform Enterprise HA

## Architecture

![basic diagram](https://github.com/hashicorp/terraform-aws-terraform-enterprise/blob/v0.0.1-beta/assets/aws_diagram.jpg?raw=true)
![basic diagram](https://github.com/hashicorp/terraform-aws-terraform-enterprise/blob/master/assets/aws_diagram.jpg?raw=true)
_example architecture_

Please contact your Technical Account Manager for more information, and support for any issues you have.

## Examples

Please see the [examples directory](https://github.com/hashicorp/terraform-aws-terraform-enterprise/tree/master/examples/) for more extensive examples.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| distribution | Type of linux distribution to use. (ubuntu or rhel) | string | n/a | yes |
| domain | Route53 Domain to manage DNS under | string | n/a | yes |
| license\_file | path to Replicated license file | string | n/a | yes |
| primary\_count | The number of additional cluster master nodes to run | string | n/a | yes |
| secondary\_count | The number of secondary cluster nodes to run | string | n/a | yes |
| vpc\_id | AWS VPC id to install into | string | n/a | yes |
| airgap\_installer\_url | URL to replicated's airgap installer package | string | `"https://install.terraform.io/installer/replicated-v5.tar.gz"` | no |
| airgap\_package\_url | signed URL to download the package | string | `""` | no |
| allow_list | List of CIDRs we allow to access the PTFE infrastructure | list | `[]` | no |
| ami | AMI to launch instance with; defaults to latest Ubuntu Xenial | string | `""` | no |
| aws\_access\_key\_id | AWS access key id to connect to s3 with | string | `""` | no |
| aws\_secret\_access\_key | AWS secret access key to connect to s3 with | string | `""` | no |
| ca_bundle_url | URL to Custom CA bundle used for outgoing connections| string | `"none"` | no |
| cert\_domain | domain to search for ACM certificate with (default is *.domain) | string | `""` | no |
| cidr | cidr block for vpc | string | `"10.0.0.0/16"` | no |
| encryption\_password | encryption password to use as root secret (default is autogenerated) | string | `""` | no |
| hostname | hostname to assign to cluster under domain (default is autogenerated one) | string | `""` | no |
| http\_proxy\_url | HTTP(S) Proxy URL | string | `""` | no |
| iact\_subnet\_list | List of subnets to allow to access Initial Admin Creation Token (IACT) API. https://www.terraform.io/docs/enterprise/private/automating-initial-user.html | string | `""` | no |
| iact\_subnet\_time\_limit | Amount of time to allow access to IACT API after initial boot | string | `""` | no |
| import\_key | an ssh pub key to import to all machines | string | `""` | no |
| install\_mode | Installation mode | string | `"demo"` | no |
| postgresql\_address | address to connect to external postgresql database at | string | `""` | no |
| postgresql\_database | database name to use in exetrnal postgresql database | string | `""` | no |
| postgresql\_extra\_params | additional connection string parameters (must be url query params) | string | `""` | no |
| postgresql\_password | password to connect to external postgresql database as | string | `""` | no |
| postgresql\_user | user to connect to external postgresql database as | string | `""` | no |
| primary\_instance\_type | ec2 instance type | string | `"m4.xlarge"` | no |
| ptfe\_url | URL to the PTFE tool | string | `"https://install.terraform.io/installer/ptfe.zip"` | no |
| region | aws region where resources will be created | string | `"us-west-2"` | no |
| repl\_cidr | Specify a non-standard CIDR range for the replicated services. The default is `10.96.0.0/12` | string | `""` | no |
| s3\_bucket | S3 bucket to store objects into | string | `""` | no |
| s3\_region | Region of the S3 bucket | string | `""` | no |
| secondary\_instance\_type | ec2 instance type (Defaults to `primary_instance_type` if not set.) | string | `""` | no |
| ssh\_user | the user to connect to the instance as | string | `""` | no |
| startup\_script | shell to run when primary instance boots | string | `""` | no |
| subnet\_tags | tags to use to match subnets to use | map | `{}` | no |
| update\_route53 | whether or not to automatically update route53 records for the cluster | string | `"true"` | no |
| volume\_size | size of the root volume in gb | string | `"100"` | no |
| weave\_cidr | Specify a non-standard CIDR range for weave. The default is `10.32.0.0/12` | string | `""` | no |
Please see the [inputs documentation](https://registry.terraform.io/modules/hashicorp/terraform-enterprise/aws/?tab=inputs)

Repository versions of the inputs documentation can be found in [docs/inputs.md](docs/inputs.md)

## Outputs

| Name | Description |
|------|-------------|
| iam\_role | The name of the IAM role being used |
| install\_id | The installation ID for TFE |
| lb\_endpoint | The load-balancer endpoint URI |
| primary\_public\_ip | The public IP address of the primary VMs |
| ptfe\_endpoint | The accessible PTFE URI |
| ptfe\_health\_check | The PTFE URI used for the health check |
| replicated\_console\_password | The Replicated console password |
| replicated\_console\_url | The Replicated Console URL |
| ssh\_config\_file | The path to the SSH configuration file |
| ssh\_private\_key | The SSH private key |
Please see the [outputs documentation](https://registry.terraform.io/modules/hashicorp/terraform-enterprise/aws/?tab=outputs)

Repository versions of the outputs documentation can be found in [docs/outputs.md](docs/outputs.md)
47 changes: 47 additions & 0 deletions docs/inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Terraform Enterprise: Clustering

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| domain | Route53 Domain to manage DNS under | string | n/a | yes |
| license\_file | path to license file | string | n/a | yes |
| vpc\_id | AWS VPC id to install into | string | n/a | yes |
| airgap\_installer\_url | URL to airgap installer package | string | `"https://s3.amazonaws.com/replicated-airgap-work/replicated__docker__kubernetes.tar.gz"` | no |
| airgap\_package\_url | signed URL to download the package | string | `""` | no |
| allow\_list | List of CIDRs we allow to access the infrastructure | list | `[]` | no |
| ami | AMI to launch instance with; defaults to latest Ubuntu Xenial | string | `""` | no |
| aws\_access\_key\_id | AWS access key id to connect to s3 with | string | `""` | no |
| aws\_secret\_access\_key | AWS secret access key to connect to s3 with | string | `""` | no |
| ca\_bundle\_url | URL to Custom CA bundle used for outgoing connections | string | `"none"` | no |
| cert\_domain | domain to search for ACM certificate with (default is *.domain) | string | `""` | no |
| cidr | cidr block for vpc | string | `"10.0.0.0/16"` | no |
| distribution | Type of linux distribution to use. (ubuntu or rhel) | string | `"ubuntu"` | no |
| encryption\_password | encryption password to use as root secret (default is autogenerated) | string | `""` | no |
| hostname | hostname to assign to cluster under domain (default is autogenerated one) | string | `""` | no |
| http\_proxy\_url | HTTP(S) Proxy URL | string | `""` | no |
| iact\_subnet\_list | List of subnets to allow to access Initial Admin Creation Token (IACT) API. https://www.terraform.io/docs/enterprise/private/automating-initial-user.html | string | `""` | no |
| iact\_subnet\_time\_limit | Amount of time to allow access to IACT API after initial boot | string | `""` | no |
| import\_key | an ssh pub key to import to all machines | string | `""` | no |
| installer\_url | URL to the cluster setup tool | string | `"https://install.terraform.io/installer/ptfe.zip"` | no |
| postgresql\_address | address to connect to external postgresql database at | string | `""` | no |
| postgresql\_database | database name to use in exetrnal postgresql database | string | `""` | no |
| postgresql\_extra\_params | additional connection string parameters (must be url query params) | string | `""` | no |
| postgresql\_password | password to connect to external postgresql database as | string | `""` | no |
| postgresql\_user | user to connect to external postgresql database as | string | `""` | no |
| prefix | Name prefix for resource names and tags | string | `"tfe"` | no |
| primary\_count | The number of primary cluster master nodes to run, only 3 support now. | string | `"3"` | no |
| primary\_instance\_type | ec2 instance type | string | `"m4.xlarge"` | no |
| region | aws region where resources will be created | string | `"us-west-2"` | no |
| repl\_cidr | Specify a non-standard CIDR range for the replicated services. The default is 10.96.0.0/12 | string | `""` | no |
| s3\_bucket | S3 bucket to store objects into | string | `""` | no |
| s3\_region | Region of the S3 bucket | string | `""` | no |
| secondary\_count | The number of secondary cluster nodes to run | string | `"5"` | no |
| secondary\_instance\_type | ec2 instance type (Defaults to `primary_instance_type` if not set.) | string | `""` | no |
| ssh\_user | the user to connect to the instance as | string | `""` | no |
| startup\_script | shell script to run when primary instance boots the first time | string | `""` | no |
| subnet\_tags | tags to use to match subnets to use | map | `{}` | no |
| update\_route53 | whether or not to automatically update route53 records for the cluster | string | `"true"` | no |
| volume\_size | size of the root volume in gb | string | `"100"` | no |
| weave\_cidr | Specify a non-standard CIDR range for weave. The default is 10.32.0.0/12 | string | `""` | no |

16 changes: 16 additions & 0 deletions docs/outputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Terraform Enterprise: Clustering

## Outputs

| Name | Description |
|------|-------------|
| application\_endpoint | |
| application\_health\_check | |
| iam\_role | |
| install\_id | |
| installer\_dashboard\_password | |
| installer\_dashboard\_url | |
| primary\_public\_ip | |
| ssh\_config\_file | |
| ssh\_private\_key | |

12 changes: 12 additions & 0 deletions modules/common-user-vpc/docs/inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Terraform Enterprise: Clustering

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| prefix | Prefix for resource names | string | n/a | yes |
| vpc\_id | AWS VPC id to install into | string | n/a | yes |
| allow\_list | list of CIDRs we allow to access the infrastructure | list | `[]` | no |
| cidr | cidr block for vpc | string | `"10.0.0.0/16"` | no |
| subnet\_tags | tags to use to match subnets to use | map | `{}` | no |

19 changes: 19 additions & 0 deletions modules/common-user-vpc/docs/outputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Terraform Enterprise: Clustering

## Outputs

| Name | Description |
|------|-------------|
| allow\_ptfe\_sg\_id | |
| availability\_zones | |
| collect\_diag\_file | |
| install\_id | |
| intra\_vpc\_and\_egress\_sg\_id | |
| private\_subnets | |
| private\_subnets\_cidr\_blocks | |
| public\_subnets | |
| public\_subnets\_cidr\_blocks | |
| ssh\_key\_name | |
| ssh\_priv\_key\_file | |
| vpc\_id | |

8 changes: 8 additions & 0 deletions modules/common-with-base-vpc/docs/inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Terraform Enterprise: Clustering

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| cidr | cidr block for vpc | string | `"10.0.0.0/16"` | no |

21 changes: 21 additions & 0 deletions modules/common-with-base-vpc/docs/outputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Terraform Enterprise: Clustering

## Outputs

| Name | Description |
|------|-------------|
| allow\_ptfe\_sg\_id | |
| availability\_zones | |
| collect\_diag\_file | |
| database\_subnet\_group | |
| domain | |
| install\_id | |
| intra\_vpc\_and\_egress\_sg\_id | |
| private\_subnets | |
| private\_subnets\_cidr\_blocks | |
| public\_subnets | |
| public\_subnets\_cidr\_blocks | |
| ssh\_key\_name | |
| ssh\_priv\_key\_file | |
| vpc\_id | |

3 changes: 3 additions & 0 deletions modules/external-services/docs/inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Terraform Enterprise: Clustering


3 changes: 3 additions & 0 deletions modules/external-services/docs/outputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Terraform Enterprise: Clustering


17 changes: 17 additions & 0 deletions modules/lb/docs/inputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Terraform Enterprise: Clustering

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| domain | this is used to find an existing issued wildcard cert and route53 zone | string | n/a | yes |
| install\_id | the ID of the install | string | n/a | yes |
| prefix | Prefix for resources | string | n/a | yes |
| private\_subnets\_cidr\_blocks | list of CIDRs for the private subnets | list | n/a | yes |
| public\_subnets | list of public subnets | list | n/a | yes |
| public\_subnets\_cidr\_blocks | list of CIDRs for the public subnets | list | n/a | yes |
| vpc\_id | the ID of the VPC | string | n/a | yes |
| cert\_domain | domain to search for ACM certificate with (default is *.domain) | string | `""` | no |
| hostname | hostname to assign to cluster under domain (default is autogenerated one) | string | `""` | no |
| update\_route53 | indicate if route53 should be updated automatically | string | `"true"` | no |

13 changes: 13 additions & 0 deletions modules/lb/docs/outputs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Terraform Enterprise: Clustering

## Outputs

| Name | Description |
|------|-------------|
| admin\_group | |
| endpoint | |
| https\_group | |
| lb\_endpoint | |
| lb\_id | |
| sg\_lb\_to\_instance | |

0 comments on commit 09b6416

Please sign in to comment.