Skip to content

Commit

Permalink
Merge pull request #1 from umotif-public/feat/git-hooks
Browse files Browse the repository at this point in the history
add git hooks and update docs
  • Loading branch information
umotif-olascu authored Feb 5, 2020
2 parents e931cfa + fe0f26d commit 4cd062b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 39 deletions.
25 changes: 25 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: check-added-large-files
args: ['--maxkb=500']
- id: check-executables-have-shebangs
- id: pretty-format-json
args: ['--autofix', '--no-sort-keys', '--indent=2']
- id: check-byte-order-marker
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-symlinks
- id: detect-private-key
- id: check-merge-conflict
- id: detect-aws-credentials
args: ['--allow-missing-credentials']
- id: trailing-whitespace
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.25.0
hooks:
- id: terraform_fmt
- id: terraform_docs
- id: terraform_tflint
40 changes: 9 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,15 @@ ifneq (,)
.error This Makefile requires GNU Make.
endif

.PHONY: gen _gen-main _update-tf-docs
.PHONY: hooks validate

CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TF_EXAMPLES = $(sort $(dir $(wildcard $(CURRENT_DIR)examples/*/)))
TF_DOCS_VERSION = 0.6.0
help:
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

# Adjust your delimiter here or overwrite via make arguments
DELIM_START = <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
DELIM_CLOSE = <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
hooks: ## Commit hooks setup
@pre-commit install
@pre-commit gc
@pre-commit autoupdate

gen: _update-tf-docs
@echo "################################################################################"
@echo "# Terraform-docs generate"
@echo "################################################################################"
@$(MAKE) --no-print-directory _gen-main

_gen-main:
@echo "------------------------------------------------------------"
@echo "# Main module"
@echo "------------------------------------------------------------"
@if docker run --rm \
-v $(CURRENT_DIR):/data \
-e DELIM_START='$(DELIM_START)' \
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
cytopia/terraform-docs:$(TF_DOCS_VERSION) \
terraform-docs-replace-012 --sort-inputs-by-required --with-aggregate-type-defaults md README.md; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi

_update-tf-docs:
docker pull cytopia/terraform-docs:$(TF_DOCS_VERSION)
validate: ## Validate files with pre-commit hooks
@pre-commit run --all-files
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Terraform 0.12. Pin module version to `~> v1.0`. Submit pull-requests to `master
module "alb" {
source = "umotif-public/alb/aws"
version = "~> 1.0"
name_prefix = "complete-alb"
load_balancer_type = "application"
Expand Down Expand Up @@ -80,25 +80,25 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [linkedin](http

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| name\_prefix | A prefix used for naming resources. | string | n/a | yes |
| subnets | A list of subnet IDs to attach to the LB. | list(string) | n/a | yes |
| vpc\_id | The VPC ID. | string | n/a | yes |
| access\_logs | An Access Logs block. | map(string) | `{}` | no |
| cidr\_blocks\_redirect | List of CIDR ranges to allow at security group level. Defaults to 0.0.0.0/0 | list(string) | `[ "0.0.0.0/0" ]` | no |
| description | The description of the all resources. | string | `"Managed by Terraform"` | no |
| enable\_cross\_zone\_load\_balancing | If true, cross-zone load balancing of the load balancer will be enabled. This is a network load balancer feature. | bool | `"false"` | no |
| enable\_deletion\_protection | If true, deletion of the load balancer will be disabled via the AWS API. This will prevent Terraform from deleting the load balancer. | bool | `"false"` | no |
| enable\_http2 | Indicates whether HTTP/2 is enabled in application load balancers. | bool | `"true"` | no |
| enable\_http\_to\_https\_redirect | Enable default redirect rule from port 80 to 443. | bool | `"false"` | no |
| idle\_timeout | (Optional) The time in seconds that the connection is allowed to be idle. Only valid for Load Balancers of type application. | number | `"60"` | no |
| idle\_timeout | \(Optional\) The time in seconds that the connection is allowed to be idle. Only valid for Load Balancers of type application. | number | `"60"` | no |
| internal | Provision an internal load balancer. Defaults to false. | bool | `"false"` | no |
| ip\_address\_type | The type of IP addresses used by the subnets for your load balancer. The possible values are ipv4 and dualstack. | string | `"ipv4"` | no |
| load\_balancer\_create\_timeout | Timeout value when creating the ALB. | string | `"15m"` | no |
| load\_balancer\_delete\_timeout | Timeout value when deleting the ALB. | string | `"15m"` | no |
| load\_balancer\_type | Type of load balancer to provision (network or application). | string | `"application"` | no |
| load\_balancer\_type | Type of load balancer to provision \(network or application\). | string | `"application"` | no |
| load\_balancer\_update\_timeout | Timeout value when updating the ALB. | string | `"15m"` | no |
| name\_prefix | A prefix used for naming resources. | string | n/a | yes |
| subnet\_mapping | A list of subnet mapping blocks describing subnets to attach to network load balancer | list(map(string)) | `[]` | no |
| tags | A map of tags (key-value pairs) passed to resources. | map(string) | `{}` | no |
| subnets | A list of subnet IDs to attach to the LB. | list(string) | n/a | yes |
| tags | A map of tags \(key-value pairs\) passed to resources. | map(string) | `{}` | no |
| vpc\_id | The VPC ID. | string | n/a | yes |

## Outputs

Expand All @@ -110,10 +110,25 @@ Module managed by [Marcin Cuber](https://github.com/marcincuber) [linkedin](http
| name | The name of the load balancer. |
| origin\_id | First part of the DNS name of the load balancer. |
| security\_group\_id | The ID of the security group. |
| zone\_id | The canonical hosted zone ID of the load balancer (to be used in a Route 53 Alias record). |
| zone\_id | The canonical hosted zone ID of the load balancer \(to be used in a Route 53 Alias record\). |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

## License

See LICENSE for full details.

## Pre-commit hooks

### Install dependencies

* [`pre-commit`](https://pre-commit.com/#install)
* [`terraform-docs`](https://github.com/segmentio/terraform-docs) required for `terraform_docs` hooks.
* [`TFLint`](https://github.com/terraform-linters/tflint) required for `terraform_tflint` hook.

#### MacOS

```bash
brew install pre-commit terraform-docs tflint
```

0 comments on commit 4cd062b

Please sign in to comment.