Skip to content

Commit

Permalink
Merge pull request #7 from Flaconi/TF013update
Browse files Browse the repository at this point in the history
Update to TF0.13 and be compatible with TF1.0
  • Loading branch information
Maohsiang @github committed Sep 29, 2021
2 parents 0eaf6ab + c384ad8 commit 96c45d1
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 99 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @Flaconi/devops
26 changes: 26 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# <Name of PR>

## Description
<!-- Add Brief description of what this PR does and why it is needed. -->


## Testing Instructions
<!-- Add bullet points for how to test this PR -->
<!-- * What is the desired goal one can test again -->
<!-- * How to test against the desired goal -->
<!-- * Optionally add dry-run instructions -->


## How to roll out
<!-- Add information for how to roll out this PR -->
<!-- * How to roll out (cli or CI/CD tools) -->
<!-- * Where to roll out (affected environments) -->


## Notes
<!-- Optional. Ancillary topics, caveats, alternative strategies that didn't work out, anything else. -->


## Demo
<!-- Optional. If you have already done a test run, attach your demo output -->

24 changes: 24 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: '$NEXT_MINOR_VERSION 🌈'
tag-template: '$NEXT_MINOR_VERSION'
categories:
- title: '🚀 Features'
labels:
- feature
- enhancement
- title: '🐛 Bug Fixes'
labels:
- fix
- bugfix
- bug
- title: '🧰 Maintenance'
labels:
- chore
- dependencies
change-template: '- $TITLE @$AUTHOR (#$NUMBER)'
branches:
- master
template: |
## What's Changed
$CHANGES
22 changes: 22 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---

###
### Runs tests on master branch
###

name: "master branch"
on:
schedule:
- cron: "0 4 * * 1"

jobs:
test:
runs-on: ubuntu-latest
name: "Terraform test"
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: "make test"
run: |
make test
15 changes: 15 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release Drafter

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- master

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 changes: 43 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

###
### Runs checks on whole repository: lint, docs, test
###

name: terraform
on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
name: "Lint"
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: "make lint"
run: |
make lint
docs:
runs-on: ubuntu-latest
name: "Terraform docs"
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: "make gen"
run: |
make gen
git diff --quiet || { echo "Build Changes"; git diff; git status; false; }
test:
runs-on: ubuntu-latest
name: "Terraform test"
steps:
- name: Checkout repository
uses: actions/checkout@master

- name: "make test"
run: |
make test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
terraform.tfstate
*.tfstate*
terraform.tfvars

# Exclude the providers lock file introduced by TF0.14
.terraform.lock.hcl
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

54 changes: 19 additions & 35 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ TF_EXAMPLES = $(sort $(dir $(wildcard $(CURRENT_DIR)examples/*/)))
# -------------------------------------------------------------------------------------------------
# Image versions
# -------------------------------------------------------------------------------------------------
TF_VERSION = light
TFDOCS_VERSION = latest
TF_VERSION = 0.13.7
TFDOCS_VERSION = 0.15.0-0.29
FL_VERSION = 0.4


Expand All @@ -21,7 +21,7 @@ FL_VERSION = 0.4
DELIM_START = <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
DELIM_CLOSE = <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
# What arguments to append to terraform-docs command
TFDOCS_ARGS = --sort-by-required
TFDOCS_ARGS = --sort-by required

FL_IGNORE = .git/,.github/,*.terraform/

Expand Down Expand Up @@ -52,58 +52,42 @@ lint:
$(MAKE) --no-print-directory _lint-files
$(MAKE) --no-print-directory _lint-fmt

@if docker run -it --rm -v "$(CURRENT_DIR):/t:ro" --workdir "/t" hashicorp/terraform:light \
fmt -check=true -diff=true -write=false -list=true .; then \
echo "OK"; \
else \
echo "Failed"; \
exit 1; \
fi;
@echo


test: _pull-tf
@$(foreach example,\
$(TF_EXAMPLES),\
DOCKER_PATH="/t/examples/$(notdir $(patsubst %/,%,$(example)))"; \
echo "################################################################################"; \
echo "# Terraform init: $${DOCKER_PATH}"; \
echo "# examples/$$( basename $${DOCKER_PATH} )"; \
echo "################################################################################"; \
if docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:light \
echo; \
echo "------------------------------------------------------------"; \
echo "# Terraform init"; \
echo "------------------------------------------------------------"; \
if docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:$(TF_VERSION) \
init \
-verify-plugins=true \
-lock=false \
-upgrade=true \
-reconfigure \
-input=false \
-get-plugins=true \
-get=true \
.; then \
-get=true; then \
echo "OK"; \
else \
echo "Failed"; \
docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:light -rf .terraform/ || true; \
docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
exit 1; \
fi; \
echo; \
)
@$(foreach example,\
$(TF_EXAMPLES),\
DOCKER_PATH="/t/examples/$(notdir $(patsubst %/,%,$(example)))"; \
echo "################################################################################"; \
echo "# Terraform validate: $${DOCKER_PATH}"; \
echo "################################################################################"; \
if docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:light \
echo "------------------------------------------------------------"; \
echo "# Terraform validate"; \
echo "------------------------------------------------------------"; \
if docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" hashicorp/terraform:$(TF_VERSION) \
validate \
.; then \
echo "OK"; \
docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:light -rf .terraform/ || true; \
else \
echo "Failed"; \
docker run -it --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:light -rf .terraform/ || true; \
docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t" --workdir "$${DOCKER_PATH}" --entrypoint=rm hashicorp/terraform:$(TF_VERSION) -rf .terraform/ || true; \
exit 1; \
fi; \
echo; \
)


Expand All @@ -119,7 +103,7 @@ _gen-main:
-e DELIM_START='$(DELIM_START)' \
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
cytopia/terraform-docs:$(TFDOCS_VERSION) \
terraform-docs-replace-012 $(TFDOCS_ARGS) md README.md; then \
terraform-docs-replace $(TFDOCS_ARGS) markdown README.md; then \
echo "OK"; \
else \
echo "Failed"; \
Expand All @@ -138,7 +122,7 @@ _gen-examples:
-e DELIM_START='$(DELIM_START)' \
-e DELIM_CLOSE='$(DELIM_CLOSE)' \
cytopia/terraform-docs:$(TFDOCS_VERSION) \
terraform-docs-replace-012 $(TFDOCS_ARGS) md $${DOCKER_PATH}/README.md; then \
terraform-docs-replace $(TFDOCS_ARGS) markdown $${DOCKER_PATH}/README.md; then \
echo "OK"; \
else \
echo "Failed"; \
Expand Down Expand Up @@ -167,7 +151,7 @@ _lint-fmt: _pull-tf
@echo "------------------------------------------------------------"
@echo "# *.tf files"
@echo "------------------------------------------------------------"
@if docker run -it --rm -v "$(CURRENT_DIR):/t:ro" --workdir "/t" hashicorp/terraform:$(TF_VERSION) \
@if docker run $$(tty -s && echo "-it" || echo) --rm -v "$(CURRENT_DIR):/t:ro" --workdir "/t" hashicorp/terraform:$(TF_VERSION) \
fmt -check=true -diff=true -write=false -list=true .; then \
echo "OK"; \
else \
Expand Down
51 changes: 35 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
**[Outputs](#outputs)** |
**[License](#license)**

[![Build Status](https://travis-ci.org/cytopia/terraform-aws-route53-zone.svg?branch=master)](https://travis-ci.org/cytopia/terraform-aws-route53-zone)
[![Tag](https://img.shields.io/github/tag/cytopia/terraform-aws-route53-zone.svg)](https://github.com/cytopia/terraform-aws-route53-zone/releases)
[![Terraform](https://img.shields.io/badge/Terraform--registry-aws--route53--zone-brightgreen.svg)](https://registry.terraform.io/modules/cytopia/route53-zone/aws/)
![terraform workflow](https://github.com/flaconi/terraform-aws-route53-zone/actions/workflows/terraform.yml/badge.svg)
![master workflow](https://github.com/flaconi/terraform-aws-route53-zone/actions/workflows/master.yml/badge.svg)
[![Tag](https://img.shields.io/github/tag/Flaconi/terraform-aws-route53-zone.svg)](https://github.com/Flaconi/terraform-aws-route53-zone/releases)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

This Terraform module is able to create an arbitrary number of **delegation sets**, **public** and **private** hosted zones for root and delegated domains.
Expand Down Expand Up @@ -169,34 +169,53 @@ terraform import 'aws_route53_zone.public_delegated_secondary_zones["sub.www.exa
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

No requirements.
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3 |

## Providers

| Name | Version |
|------|---------|
| aws | n/a |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_route53_delegation_set.delegation_sets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_delegation_set) | resource |
| [aws_route53_record.public_delegated_secondary_ns_records](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource |
| [aws_route53_zone.private_root_zones](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
| [aws_route53_zone.public_delegated_secondary_zones](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
| [aws_route53_zone.public_root_zones](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| comment | Default comment to add to all resources. | `string` | `"Managed by Terraform"` | no |
| delegation\_sets | A list of delegation sets to create. You only need to specify the alias names that can then be referenced by other variables in this module via this unique name. A delegation set is a set of four authoritative name servers that you can use with more than one hosted zone. By default, Route 53 assigns a random selection of name servers to each new hosted zone. To make it easier to migrate DNS service to Route 53 for a large number of domains, you can create a reusable delegation set and then associate the reusable delegation set with new hosted zones. | `list(string)` | `[]` | no |
| private\_root\_zones | Private Route53 root zone (also allows subdomain if this is your root starting point). Note, by default the default VPC will always be attached, even if vpc\_ids or vpc\_tags are empty. | <pre>list(object({<br> name = string,<br> vpc_ids = list(object({<br> id = string,<br> region = string,<br> })),<br> }))</pre> | `[]` | no |
| public\_delegated\_secondary\_zones | A list of public Route53 delegated secondary zones. Each item must specify its 'parent' by name, which must match the name defined in the 'public\_root\_zones' variables and must also be exactly one level deeper than the corresponding root zone item. By doing so, this module will automatically add nameservers into the root zone to create the delegation. You can also attach a delegation\_set to this zone by its reference name (if it has been defined in the 'delegation\_sets' list) or set it to 'null' to use no delegation set. Additionally you can also define your own name servers for this zone by specifying them in the `ns_list` list or just leave the list empty to use AWS default name server. | <pre>list(object({<br> name = string,<br> parent = string,<br> ns_ttl = number,<br> ns_list = list(string),<br> delegation_set = string,<br> }))</pre> | `[]` | no |
| public\_root\_zones | A list of public Route53 root zones. A 'root zone' can be anything from a tld to any level of subdomain, if and only if this is your root starting point for this (sub-)domain on the current AWS account. You can also attach a delegation\_set to this root zone by its reference name (if it has been defined in the 'delegation\_sets' list) or set it to 'null' to use no delegation set. | <pre>list(object({<br> name = string,<br> delegation_set = string,<br> }))</pre> | `[]` | no |
| tags | Default tags to additionally apply to all resources. | `map` | `{}` | no |
| <a name="input_comment"></a> [comment](#input\_comment) | Default comment to add to all resources. | `string` | `"Managed by Terraform"` | no |
| <a name="input_delegation_sets"></a> [delegation\_sets](#input\_delegation\_sets) | A list of delegation sets to create. You only need to specify the alias names that can then be referenced by other variables in this module via this unique name. A delegation set is a set of four authoritative name servers that you can use with more than one hosted zone. By default, Route 53 assigns a random selection of name servers to each new hosted zone. To make it easier to migrate DNS service to Route 53 for a large number of domains, you can create a reusable delegation set and then associate the reusable delegation set with new hosted zones. | `list(string)` | `[]` | no |
| <a name="input_private_root_zones"></a> [private\_root\_zones](#input\_private\_root\_zones) | Private Route53 root zone (also allows subdomain if this is your root starting point). Note, by default the default VPC will always be attached, even if vpc\_ids or vpc\_tags are empty. | <pre>list(object({<br> name = string,<br> vpc_ids = list(object({<br> id = string,<br> region = string,<br> })),<br> }))</pre> | `[]` | no |
| <a name="input_public_delegated_secondary_zones"></a> [public\_delegated\_secondary\_zones](#input\_public\_delegated\_secondary\_zones) | A list of public Route53 delegated secondary zones. Each item must specify its 'parent' by name, which must match the name defined in the 'public\_root\_zones' variables and must also be exactly one level deeper than the corresponding root zone item. By doing so, this module will automatically add nameservers into the root zone to create the delegation. You can also attach a delegation\_set to this zone by its reference name (if it has been defined in the 'delegation\_sets' list) or set it to 'null' to use no delegation set. Additionally you can also define your own name servers for this zone by specifying them in the `ns_list` list or just leave the list empty to use AWS default name server. | <pre>list(object({<br> name = string,<br> parent = string,<br> ns_ttl = number,<br> ns_list = list(string),<br> delegation_set = string,<br> }))</pre> | `[]` | no |
| <a name="input_public_root_zones"></a> [public\_root\_zones](#input\_public\_root\_zones) | A list of public Route53 root zones. A 'root zone' can be anything from a tld to any level of subdomain, if and only if this is your root starting point for this (sub-)domain on the current AWS account. You can also attach a delegation\_set to this root zone by its reference name (if it has been defined in the 'delegation\_sets' list) or set it to 'null' to use no delegation set. | <pre>list(object({<br> name = string,<br> delegation_set = string,<br> }))</pre> | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | Default tags to additionally apply to all resources. | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| delegation\_sets | Created delegation sets. |
| private\_root\_zones | Created private root zones. |
| public\_delegated\_secondary\_ns\_records | Created NS records in your root zone for delegated secondary zones. |
| public\_delegated\_secondary\_zones | Created public delegated secondary zones. |
| public\_root\_zones | Created public root zones. |
| <a name="output_delegation_sets"></a> [delegation\_sets](#output\_delegation\_sets) | Created delegation sets. |
| <a name="output_private_root_zones"></a> [private\_root\_zones](#output\_private\_root\_zones) | Created private root zones. |
| <a name="output_public_delegated_secondary_ns_records"></a> [public\_delegated\_secondary\_ns\_records](#output\_public\_delegated\_secondary\_ns\_records) | Created NS records in your root zone for delegated secondary zones. |
| <a name="output_public_delegated_secondary_zones"></a> [public\_delegated\_secondary\_zones](#output\_public\_delegated\_secondary\_zones) | Created public delegated secondary zones. |
| <a name="output_public_root_zones"></a> [public\_root\_zones](#output\_public\_root\_zones) | Created public root zones. |

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

Expand Down
Loading

0 comments on commit 96c45d1

Please sign in to comment.