Skip to content

Commit e551bfa

Browse files
committed
improve docs and auto generating of inputs/outputs
1 parent 1b41730 commit e551bfa

File tree

3 files changed

+163
-2
lines changed

3 files changed

+163
-2
lines changed

Makefile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
ifneq (,)
2+
.error This Makefile requires GNU Make.
3+
endif
4+
5+
.PHONY: gen _gen-main _gen-examples _update-tf-docs
6+
7+
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
8+
TF_EXAMPLES = $(sort $(dir $(wildcard $(CURRENT_DIR)examples/*/)))
9+
TF_DOCS_VERSION = 0.6.0
10+
11+
# Adjust your delimiter here or overwrite via make arguments
12+
DELIM_START = <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
13+
DELIM_CLOSE = <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
14+
15+
gen: _update-tf-docs
16+
@echo "################################################################################"
17+
@echo "# Terraform-docs generate"
18+
@echo "################################################################################"
19+
@$(MAKE) --no-print-directory _gen-main
20+
@$(MAKE) --no-print-directory _gen-examples
21+
22+
_gen-main:
23+
@echo "------------------------------------------------------------"
24+
@echo "# Main module"
25+
@echo "------------------------------------------------------------"
26+
@if docker run --rm \
27+
-v $(CURRENT_DIR):/data \
28+
-e DELIM_START='$(DELIM_START)' \
29+
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
30+
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
31+
terraform-docs-replace-012 --sort-inputs-by-required --with-aggregate-type-defaults md README.md; then \
32+
echo "OK"; \
33+
else \
34+
echo "Failed"; \
35+
exit 1; \
36+
fi
37+
38+
_gen-examples:
39+
@$(foreach example,\
40+
$(TF_EXAMPLES),\
41+
DOCKER_PATH="examples/$(notdir $(patsubst %/,%,$(example)))"; \
42+
echo "------------------------------------------------------------"; \
43+
echo "# $${DOCKER_PATH}"; \
44+
echo "------------------------------------------------------------"; \
45+
if docker run --rm \
46+
-v $(CURRENT_DIR):/data \
47+
-e DELIM_START='$(DELIM_START)' \
48+
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
49+
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
50+
terraform-docs-replace-012 --sort-inputs-by-required --with-aggregate-type-defaults md $${DOCKER_PATH}/README.md; then \
51+
echo "OK"; \
52+
else \
53+
echo "Failed"; \
54+
exit 1; \
55+
fi; \
56+
)
57+
58+
_update-tf-docs:
59+
docker pull cytopia/terraform-docs:$(TF_DOCS_VERSION)

README.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# terraform-aws-ecs-fargate
2-
Terraform module to create AWS ECS FARGATE services
2+
3+
Terraform module to create AWS ECS FARGATE services.
34

45
## Terraform versions
56

@@ -53,7 +54,53 @@ Module is to be used with Terraform > 0.12.
5354

5455
## Authors
5556

56-
Module managed by [Marcin Cuber](https://github.com/marcincuber) [linkedin](https://www.linkedin.com/in/marcincuber/).
57+
Module managed by [Marcin Cuber](https://github.com/marcincuber) [LinkedIn](https://www.linkedin.com/in/marcincuber/).
58+
59+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
60+
## Inputs
61+
62+
| Name | Description | Type | Default | Required |
63+
|------|-------------|:----:|:-----:|:-----:|
64+
| cluster\_id | The Amazon Resource Name (ARN) that identifies the cluster. | string | n/a | yes |
65+
| health\_check | A health block containing health check settings for the target group. Overrides the defaults. | map(string) | n/a | yes |
66+
| lb\_arn | Arn for the LB for which the service should be attach to. | string | n/a | yes |
67+
| name\_prefix | A prefix used for naming resources. | string | n/a | yes |
68+
| private\_subnet\_ids | A list of private subnets inside the VPC | list(string) | n/a | yes |
69+
| task\_container\_image | The image used to start a container. | string | n/a | yes |
70+
| task\_container\_port | Port that the container exposes. | number | n/a | yes |
71+
| vpc\_id | The VPC ID. | string | n/a | yes |
72+
| container\_name | Optional name for the container to be used instead of name_prefix. | string | `""` | no |
73+
| deployment\_controller\_type | Type of deployment controller. Valid values: CODE_DEPLOY, ECS. | string | `"ECS"` | no |
74+
| deployment\_maximum\_percent | The upper limit of the number of running tasks that can be running in a service during a deployment | number | `"200"` | no |
75+
| deployment\_minimum\_healthy\_percent | The lower limit of the number of running tasks that must remain running and healthy in a service during a deployment | number | `"50"` | no |
76+
| desired\_count | The number of instances of the task definitions to place and keep running. | number | `"1"` | no |
77+
| health\_check\_grace\_period\_seconds | Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 7200. Only valid for services configured to use load balancers. | number | `"300"` | no |
78+
| log\_retention\_in\_days | Number of days the logs will be retained in CloudWatch. | number | `"30"` | no |
79+
| repository\_credentials | name or ARN of a secrets manager secret (arn:aws:secretsmanager:region:aws_account_id:secret:secret_name) | string | `""` | no |
80+
| repository\_credentials\_kms\_key | key id, key ARN, alias name or alias ARN of the key that encrypted the repository credentials | string | `"alias/aws/secretsmanager"` | no |
81+
| service\_registry\_arn | ARN of aws_service_discovery_service resource | string | `""` | no |
82+
| tags | A map of tags (key-value pairs) passed to resources. | map(string) | `{}` | no |
83+
| task\_container\_assign\_public\_ip | Assigned public IP to the container. | bool | `"false"` | no |
84+
| task\_container\_command | The command that is passed to the container. | list(string) | `[]` | no |
85+
| task\_container\_environment | The environment variables to pass to a container. | map(string) | `{}` | no |
86+
| task\_container\_protocol | Protocol that the container exposes. | string | `"HTTP"` | no |
87+
| task\_definition\_cpu | Amount of CPU to reserve for the task. | number | `"256"` | no |
88+
| task\_definition\_memory | The soft limit (in MiB) of memory to reserve for the container. | number | `"512"` | no |
89+
90+
## Outputs
91+
92+
| Name | Description |
93+
|------|-------------|
94+
| log\_group\_name | The name of the Cloudwatch log group for the task. |
95+
| service\_arn | The Amazon Resource Name (ARN) that identifies the ECS service. |
96+
| service\_name | The name of the service. |
97+
| service\_sg\_id | The Amazon Resource Name (ARN) that identifies the service security group. |
98+
| target\_group\_arn | The ARN of the Target Group used by Load Balancer. |
99+
| target\_group\_name | The Name of the Target Group used by Load Balancer. |
100+
| task\_role\_arn | The Amazon Resource Name (ARN) specifying the ECS service role. |
101+
| task\_role\_name | The name of the Fargate task service role. |
102+
103+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
57104

58105
## License
59106

examples/core/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
## Example deployment flow
3+
4+
```bash
5+
terraform init
6+
terraform validate
7+
terraform plan
8+
terraform apply --auto-approve
9+
```
10+
11+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
12+
## Inputs
13+
14+
| Name | Description | Type | Default | Required |
15+
|------|-------------|:----:|:-----:|:-----:|
16+
| cluster\_id | The Amazon Resource Name (ARN) that identifies the cluster. | string | n/a | yes |
17+
| health\_check | A health block containing health check settings for the target group. Overrides the defaults. | map(string) | n/a | yes |
18+
| lb\_arn | Arn for the LB for which the service should be attach to. | string | n/a | yes |
19+
| name\_prefix | A prefix used for naming resources. | string | n/a | yes |
20+
| private\_subnet\_ids | A list of private subnets inside the VPC | list(string) | n/a | yes |
21+
| task\_container\_image | The image used to start a container. | string | n/a | yes |
22+
| task\_container\_port | Port that the container exposes. | number | n/a | yes |
23+
| vpc\_id | The VPC ID. | string | n/a | yes |
24+
| container\_name | Optional name for the container to be used instead of name_prefix. | string | `""` | no |
25+
| deployment\_controller\_type | Type of deployment controller. Valid values: CODE_DEPLOY, ECS. | string | `"ECS"` | no |
26+
| deployment\_maximum\_percent | The upper limit of the number of running tasks that can be running in a service during a deployment | number | `"200"` | no |
27+
| deployment\_minimum\_healthy\_percent | The lower limit of the number of running tasks that must remain running and healthy in a service during a deployment | number | `"50"` | no |
28+
| desired\_count | The number of instances of the task definitions to place and keep running. | number | `"1"` | no |
29+
| health\_check\_grace\_period\_seconds | Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown, up to 7200. Only valid for services configured to use load balancers. | number | `"300"` | no |
30+
| log\_retention\_in\_days | Number of days the logs will be retained in CloudWatch. | number | `"30"` | no |
31+
| repository\_credentials | name or ARN of a secrets manager secret (arn:aws:secretsmanager:region:aws_account_id:secret:secret_name) | string | `""` | no |
32+
| repository\_credentials\_kms\_key | key id, key ARN, alias name or alias ARN of the key that encrypted the repository credentials | string | `"alias/aws/secretsmanager"` | no |
33+
| service\_registry\_arn | ARN of aws_service_discovery_service resource | string | `""` | no |
34+
| tags | A map of tags (key-value pairs) passed to resources. | map(string) | `{}` | no |
35+
| task\_container\_assign\_public\_ip | Assigned public IP to the container. | bool | `"false"` | no |
36+
| task\_container\_command | The command that is passed to the container. | list(string) | `[]` | no |
37+
| task\_container\_environment | The environment variables to pass to a container. | map(string) | `{}` | no |
38+
| task\_container\_protocol | Protocol that the container exposes. | string | `"HTTP"` | no |
39+
| task\_definition\_cpu | Amount of CPU to reserve for the task. | number | `"256"` | no |
40+
| task\_definition\_memory | The soft limit (in MiB) of memory to reserve for the container. | number | `"512"` | no |
41+
42+
## Outputs
43+
44+
| Name | Description |
45+
|------|-------------|
46+
| log\_group\_name | The name of the Cloudwatch log group for the task. |
47+
| service\_arn | The Amazon Resource Name (ARN) that identifies the ECS service. |
48+
| service\_name | The name of the service. |
49+
| service\_sg\_id | The Amazon Resource Name (ARN) that identifies the service security group. |
50+
| target\_group\_arn | The ARN of the Target Group used by Load Balancer. |
51+
| target\_group\_name | The Name of the Target Group used by Load Balancer. |
52+
| task\_role\_arn | The Amazon Resource Name (ARN) specifying the ECS service role. |
53+
| task\_role\_name | The name of the Fargate task service role. |
54+
55+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

0 commit comments

Comments
 (0)