Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Terraform v1.x #52

Merged
merged 6 commits into from
Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.0]

- Add support for Terraform `v1.x`

## [0.5.0]

### Added
Expand Down Expand Up @@ -128,11 +132,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- markdown-link-check-disable -->

[unreleased]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.5.0...HEAD
[0.5.0]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.4.0...v0.5.0
[unreleased]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.6.0...HEAD
[0.6.0]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.5.0...v0.6.0

<!-- markdown-link-check-enable -->

[0.5.0]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.2.3...v0.3.0
[0.2.3]: https://github.com/mineiros-io/terraform-aws-route53/compare/v0.2.2...v0.2.3
Expand Down
49 changes: 34 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Set default shell to bash
SHELL := /bin/bash -o pipefail

BUILD_TOOLS_VERSION ?= v0.11.0
BUILD_TOOLS_VERSION ?= v0.12.0
BUILD_TOOLS_DOCKER_REPO ?= mineiros/build-tools
BUILD_TOOLS_DOCKER_IMAGE ?= ${BUILD_TOOLS_DOCKER_REPO}:${BUILD_TOOLS_VERSION}

#
# Some CI providers such as GitHub Actions, CircleCI, and TravisCI are setting
# the CI environment variable to a non-empty value by default to indicate that
# the current workflow is running in a Continuous Integration environment.
Expand All @@ -18,36 +17,51 @@ BUILD_TOOLS_DOCKER_IMAGE ?= ${BUILD_TOOLS_DOCKER_REPO}:${BUILD_TOOLS_VERSION}
# https://www.gnu.org/software/automake/manual/html_node/Debugging-Make-Rules.html
#
ifdef CI
TF_IN_AUTOMATION ?= yes
export TF_IN_AUTOMATION
TF_IN_AUTOMATION ?= yes
export TF_IN_AUTOMATION

V ?= 1
V ?= 1
endif

ifndef NOCOLOR
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
endif

GIT_TOPLEVEl = $(shell git rev-parse --show-toplevel)

# Generic docker run flags
DOCKER_RUN_FLAGS += -v ${GIT_TOPLEVEl}:/build
DOCKER_RUN_FLAGS += --rm
DOCKER_RUN_FLAGS += -e TF_IN_AUTOMATION

# If SSH_AUTH_SOCK is set, we forward the SSH agent of the host system into
# the docker container. This is useful when working with private repositories
# and dependencies that might need to be cloned inside the container (e.g.
# private Terraform modules).
ifdef SSH_AUTH_SOCK
DOCKER_SSH_FLAGS += -e SSH_AUTH_SOCK=/ssh-agent
DOCKER_SSH_FLAGS += -v ${SSH_AUTH_SOCK}:/ssh-agent
endif

DOCKER_AWS_FLAGS += -e AWS_ACCESS_KEY_ID
DOCKER_AWS_FLAGS += -e AWS_SECRET_ACCESS_KEY
DOCKER_AWS_FLAGS += -e AWS_SESSION_TOKEN
# If AWS_ACCESS_KEY_ID is defined, we are likely running inside an AWS provider
# module. To enable AWS authentication inside the docker container, we inject
# the relevant environment variables.
ifdef AWS_ACCESS_KEY_ID
DOCKER_AWS_FLAGS += -e AWS_ACCESS_KEY_ID
DOCKER_AWS_FLAGS += -e AWS_SECRET_ACCESS_KEY
DOCKER_AWS_FLAGS += -e AWS_SESSION_TOKEN
endif

DOCKER_FLAGS += ${DOCKER_RUN_FLAGS}
DOCKER_RUN_CMD = docker run ${DOCKER_FLAGS} ${BUILD_TOOLS_DOCKER_IMAGE}
# If GITHUB_OWNER is defined, we are likely running inside a GitHub provider
# module. To enable GitHub authentication inside the docker container,
# we inject the relevant environment variables.
ifdef GITHUB_OWNER
DOCKER_GITHUB_FLAGS += -e GITHUB_TOKEN
DOCKER_GITHUB_FLAGS += -e GITHUB_OWNER
endif

.PHONY: default
default: help
Expand All @@ -67,7 +81,9 @@ test/pre-commit:
## Run all Go tests inside a build-tools docker container. This is complementary to running 'go test ./test/...'.
.PHONY: test/unit-tests
test/unit-tests: DOCKER_FLAGS += ${DOCKER_SSH_FLAGS}
test/unit-tests: DOCKER_FLAGS += ${DOCKER_GITHUB_FLAGS}
test/unit-tests: DOCKER_FLAGS += ${DOCKER_AWS_FLAGS}
test/unit-tests: DOCKER_FLAGS += -e TF_DATA_DIR=.terratest
test/unit-tests: TEST ?= "TestUnit"
test/unit-tests:
@echo "${YELLOW}[TEST] ${GREEN}Start Running Go Tests in Docker Container.${RESET}"
Expand Down Expand Up @@ -96,7 +112,10 @@ help:
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)

# define helper functions
# Define helper functions
DOCKER_FLAGS += ${DOCKER_RUN_FLAGS}
DOCKER_RUN_CMD = docker run ${DOCKER_FLAGS} ${BUILD_TOOLS_DOCKER_IMAGE}

quiet-command = $(if ${V},${1},$(if ${2},@echo ${2} && ${1}, @${1}))
docker-run = $(call quiet-command,${DOCKER_RUN_CMD} ${1} | cat,"${YELLOW}[DOCKER RUN] ${GREEN}${1}${RESET}")
go-test = $(call quiet-command,${DOCKER_RUN_CMD} go test -v -count 1 -timeout 45m -parallel 128 ${1} | cat,"${YELLOW}[TEST] ${GREEN}${1}${RESET}")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A [Terraform](https://www.terraform.io) module to create a scalable and highly a
[Amazon Route53](https://aws.amazon.com/route53/) Domain Name System (DNS) on
[Amazon Web Services (AWS)](https://aws.amazon.com/).

***This module supports Terraform v0.15, v0.14, v0.13 as well as v0.12.20 and above
***This module supports Terraform v1.x, v0.15, v0.14, v0.13 as well as v0.12.20 and above
and is compatible with the terraform AWS provider v3 as well as v2.45 and above.***

- [Module Features](#module-features)
Expand Down Expand Up @@ -68,7 +68,7 @@ a record for `www` pointing to localhost.
```hcl
module "route53" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"
version = "~> 0.6.0"

name = "mineiros.io"

Expand Down Expand Up @@ -308,7 +308,7 @@ Copyright &copy; 2020 [Mineiros GmbH][homepage]
[badge-build]: https://mineiros.semaphoreci.com/badges/terraform-aws-route53/branches/master.svg?style=shields
[badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-aws-route53.svg?label=latest&sort=semver
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.15,%200.14,%200.13,%200.12.20+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/[email protected]?logo=slack

[badge-tf-aws]: https://img.shields.io/badge/AWS-3%20and%202.45+-F8991D.svg?logo=terraform
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
[homepage]: https://mineiros.io/?ref=terraform-aws-route53

[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.14,%200.13,%200.12.20+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/[email protected]?logo=slack
[badge-semver]: https://img.shields.io/github/v/tag/mineiros-io/terraform-aws-route53.svg?label=latest&sort=semver

Expand Down
46 changes: 1 addition & 45 deletions examples/basic-routing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,6 @@ The code in [main.tf] creates a Route53 Zone and Records for the main domain and

The `www.` subdomains are implement through CNAMES and point on the A-Records.

```hcl
module "route53" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"

name = "a-dev-mineiros.io"

records = [
{
# We don't explicitly need to set names for records that match the zone
type = "A"
alias = {
name = aws_s3_bucket.website.website_endpoint
zone_id = aws_s3_bucket.website.hosted_zone_id
evaluate_target_health = true
}
},
{
type = "CNAME"
name = "www"
records = [
"mineiros.io"
]
},
{
name = "dev"
type = "A"
ttl = 1800
records = ["203.0.113.200"]
},
{
type = "CNAME"
name = "www.dev.mineiros.io"
records = [
"dev.mineiros.io"
]
},
]
}
```

## Running the example

### Cloning the repository
Expand Down Expand Up @@ -81,13 +40,10 @@ Run `terraform destroy` to destroy all resources again.

<!-- References -->

<!-- markdown-link-check-disable -->
[main.tf]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/examples/basic-routing/main.tf
<!-- markdown-link-check-enable -->

[homepage]: https://mineiros.io/?ref=terraform-aws-route53
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.14,%200.13,%200.12.20+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/[email protected]?logo=slack
[releases-terraform]: https://github.com/hashicorp/terraform/releases
[apache20]: https://opensource.org/licenses/Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion examples/basic-routing/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ resource "aws_s3_bucket_object" "error" {

module "route53" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"
version = "~> 0.6.0"

name = "a-dev-mineiros.io"

Expand Down
2 changes: 1 addition & 1 deletion examples/delegation-set/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Run `terraform destroy` to destroy all resources again.
[main.tf]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/examples/delegation-set/main.tf
[homepage]: https://mineiros.io/?ref=terraform-aws-route53
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.14,%200.13,%200.12.20+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/[email protected]?logo=slack
[releases-terraform]: https://github.com/hashicorp/terraform/releases
[apache20]: https://opensource.org/licenses/Apache-2.0
Expand Down
4 changes: 2 additions & 2 deletions examples/delegation-set/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ provider "aws" {

module "route53-zone-with-delegation-set" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"
version = "~> 0.6.0"

name = "mineiros.io"
}
Expand All @@ -37,7 +37,7 @@ module "route53-zone-with-delegation-set" {

module "route53-zone" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"
version = "~> 0.6.0"

name = "mineiros.com"
delegation_set_id = module.route53-zone-with-delegation-set.delegation_set.id
Expand Down
48 changes: 1 addition & 47 deletions examples/failover-routing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,6 @@ The code in [main.tf] configures two Route53 Records with associated healthcheck
Route53 will route the traffic to the secondary record if the healthcheck of the
primary record reports an unhealthy status.

```hcl
resource "aws_route53_health_check" "primary" {
fqdn = "mineiros.io"
port = 80
type = "HTTP"
resource_path = "/"
failure_threshold = 5
request_interval = 30

tags = {
Name = "mineiros-io-primary-healthcheck"
}
}

module "route53" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"

name = "mineiros.io"
skip_delegation_set_creation = true

records = [
{
type = "A"
set_identifier = "primary"
failover = "PRIMARY"
# Non-alias primary records must have an associated health check
health_check_id = aws_route53_health_check.primary.id
records = [
"203.0.113.200"
]
},
{
type = "A"
set_identifier = "failover"
failover = "SECONDARY"
health_check_id = null
records = [
"203.0.113.201",
"203.0.113.202"
]
}
]
}
```

## Running the example

### Cloning the repository
Expand Down Expand Up @@ -87,7 +41,7 @@ Run `terraform destroy` to destroy all resources again.
[main.tf]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/examples/failover-routing/main.tf
[homepage]: https://mineiros.io/?ref=terraform-aws-route53
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.14,%200.13,%200.12.20+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/[email protected]?logo=slack
[releases-terraform]: https://github.com/hashicorp/terraform/releases
[apache20]: https://opensource.org/licenses/Apache-2.0
Expand Down
2 changes: 1 addition & 1 deletion examples/failover-routing/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ resource "aws_route53_health_check" "primary" {

module "route53" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"
version = "~> 0.6.0"

name = "mineiros.io"
skip_delegation_set_creation = true
Expand Down
54 changes: 1 addition & 53 deletions examples/multiple-domains-different-records/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,6 @@ The code in [main.tf] creates two zones and different records using the
convenient `name = []` shortcut.
All created zones will share the same delegation set.

```hcl
# Create multiple zones with a single module
module "zones" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"

name = [
"mineiros.io",
"mineiros.com"
]
}

# Create the records for zone a
module "zone_a_records" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"

# Wrap the reference to the zone inside a try statement to prevent ugly exceptions if we run terraform destroy
# without running a successful terraform apply before.
zone_id = try(module.zones.zone["mineiros.io"].zone_id, null)

records = [
{
type = "TXT"
ttl = 300
records = [
"Lorem ipsum"
]
}
]
}

# Create the records for zone b
module "zone_b_records" {
source = "mineiros-io/route53/aws"
version = "~> 0.5.0"

zone_id = try(module.zones.zone["mineiros.com"].zone_id, null)

records = [
{
type = "TXT"
ttl = 600
records = [
"Lorem ipsum",
"Lorem ipsum dolor sit amet"
]
}
]
}
```

## Running the example

### Cloning the repository
Expand Down Expand Up @@ -93,7 +41,7 @@ Run `terraform destroy` to destroy all resources again.
[main.tf]: https://github.com/mineiros-io/terraform-aws-route53/blob/master/examples/multiple-domains-different-records/main.tf
[homepage]: https://mineiros.io/?ref=terraform-aws-route53
[badge-license]: https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg
[badge-terraform]: https://img.shields.io/badge/terraform-0.14,%200.13,%200.12.20+-623CE4.svg?logo=terraform
[badge-terraform]: https://img.shields.io/badge/terraform-1.x%20|%200.15%200.14%20|%200.13%20|%200.12.20+-623CE4.svg?logo=terraform
[badge-slack]: https://img.shields.io/badge/[email protected]?logo=slack
[releases-terraform]: https://github.com/hashicorp/terraform/releases
[apache20]: https://opensource.org/licenses/Apache-2.0
Expand Down
Loading