项目作者: infrablocks

项目描述 :
Terraform module for creating public private DNS zones
高级语言: Ruby
项目地址: git://github.com/infrablocks/terraform-aws-dns-zones.git
创建时间: 2017-04-22T20:45:20Z
项目社区:https://github.com/infrablocks/terraform-aws-dns-zones

开源协议:MIT License

下载


Terraform AWS DNS Zones

Version
Build Pipeline
Maintainer

A Terraform module for building a public/private DNS pair in AWS.

This consists of:

  • A public DNS zone
  • A private DNS zone

Diagram of infrastructure managed by this module

Usage

To use the module, include something like the following in your Terraform
configuration:

  1. module "dns-zones" {
  2. source = "infrablocks/dns-zones/aws"
  3. version = "2.0.0"
  4. domain_name = "example.com"
  5. private_domain_name = "example.net"
  6. # Default VPC
  7. private_zone_vpc_id = "vpc-6e12c307"
  8. private_zone_vpc_region = "us-east-2"
  9. }

See the
Terraform registry entry
for more details.

Inputs

Name Description Default Required
domain_name The domain name for the public DNS zone. - Yes
private_domain_name The domain name for the private DNS zone. - Yes
private_zone_vpc_id The VPC to attach the private DNS zone to. - Yes
private_zone_vpc_region The region for the VPC. - Yes

Outputs

Name Description
public_zone_id The ID of the created public zone.
public_zone_name_servers The name servers of the created public zone.
private_zone_id The ID of the created private zone.
private_zone_name_servers The name servers of the created private zone.

Compatibility

This module is compatible with Terraform versions greater than or equal to
Terraform 1.0 and Terraform AWS provider versions greater than or equal to 3.29.

Development

Machine Requirements

In order for the build to run correctly, a few tools will need to be installed
on your development machine:

  • Ruby (3.1)
  • Bundler
  • git
  • git-crypt
  • gnupg
  • direnv
  • aws-vault

Mac OS X Setup

Installing the required tools is best managed by homebrew.

To install homebrew:

  1. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then, to install the required tools:

  1. # ruby
  2. brew install rbenv
  3. brew install ruby-build
  4. echo 'eval "$(rbenv init - bash)"' >> ~/.bash_profile
  5. echo 'eval "$(rbenv init - zsh)"' >> ~/.zshrc
  6. eval "$(rbenv init -)"
  7. rbenv install 3.1.1
  8. rbenv rehash
  9. rbenv local 3.1.1
  10. gem install bundler
  11. # git, git-crypt, gnupg
  12. brew install git
  13. brew install git-crypt
  14. brew install gnupg
  15. # aws-vault
  16. brew cask install
  17. # direnv
  18. brew install direnv
  19. echo "$(direnv hook bash)" >> ~/.bash_profile
  20. echo "$(direnv hook zsh)" >> ~/.zshrc
  21. eval "$(direnv hook $SHELL)"
  22. direnv allow <repository-directory>

Running the build

Running the build requires an AWS account and AWS credentials. You are free to
configure credentials however you like as long as an access key ID and secret
access key are available. These instructions utilise
aws-vault which makes credential
management easy and secure.

To run the full build, including unit and integration tests, execute:

  1. aws-vault exec <profile> -- ./go

To run the unit tests, execute:

  1. aws-vault exec <profile> -- ./go test:unit

To run the integration tests, execute:

  1. aws-vault exec <profile> -- ./go test:integration

To provision the module prerequisites:

  1. aws-vault exec <profile> -- ./go deployment:prerequisites:provision[<deployment_identifier>]

To provision the module contents:

  1. aws-vault exec <profile> -- ./go deployment:root:provision[<deployment_identifier>]

To destroy the module contents:

  1. aws-vault exec <profile> -- ./go deployment:root:destroy[<deployment_identifier>]

To destroy the module prerequisites:

  1. aws-vault exec <profile> -- ./go deployment:prerequisites:destroy[<deployment_identifier>]

Configuration parameters can be overridden via environment variables. For
example, to run the unit tests with a seed of "testing", execute:

  1. SEED=testing aws-vault exec <profile> -- ./go test:unit

When a seed is provided via an environment variable, infrastructure will not be
destroyed at the end of test execution. This can be useful during development
to avoid lengthy provision and destroy cycles.

To subsequently destroy unit test infrastructure for a given seed:

  1. FORCE_DESTROY=yes SEED=testing aws-vault exec <profile> -- ./go test:unit

Common Tasks

Generating an SSH key pair

To generate an SSH key pair:

  1. ssh-keygen -m PEM -t rsa -b 4096 -C integration-test@example.com -N '' -f config/secrets/keys/bastion/ssh

Generating a self-signed certificate

To generate a self signed certificate:

  1. openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365

To decrypt the resulting key:

  1. openssl rsa -in key.pem -out ssl.key

Managing CircleCI keys

To encrypt a GPG key for use by CircleCI:

  1. openssl aes-256-cbc \
  2. -e \
  3. -md sha1 \
  4. -in ./config/secrets/ci/gpg.private \
  5. -out ./.circleci/gpg.private.enc \
  6. -k "<passphrase>"

To check decryption is working correctly:

  1. openssl aes-256-cbc \
  2. -d \
  3. -md sha1 \
  4. -in ./.circleci/gpg.private.enc \
  5. -k "<passphrase>"

Contributing

Bug reports and pull requests are welcome on GitHub at
https://github.com/infrablocks/terraform-aws-dns-zones. This project is
intended to be a safe, welcoming space for collaboration, and contributors are
expected to adhere to the
Contributor Covenant code of conduct.

License

The library is available as open source under the terms of the
MIT License.