-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CCL-663: initial tf module for deploying R53 Zones with Records
- Loading branch information
Showing
5 changed files
with
149 additions
and
0 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
modules/aws/networking/route53_zone_with_records/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# core-cloud-vpc-endpoint-tf-module - VPC Endpoint Terraform Module | ||
|
||
## Example Usage | ||
``` | ||
module "r53_zone_with_rec" { | ||
source = "git::git::https://github.com/UKHomeOffice/core-cloud-terraform-modules.git//modules/aws/networking/route53_zone_with_records?ref=main" | ||
vpc_id = ["vpc-xxxxxxxxxxxxxxxxx"] | ||
r53_zone = "example.com" | ||
r53_records_as_json = jsonencode( | ||
[ | ||
{ | ||
name = "api" | ||
type = "A" | ||
alias = { | ||
name = "xxxxxxxxxxx.execute-api.eu-west-1.amazonaws.com" | ||
zone_id = "XXXXXXXXXX" | ||
} | ||
}, | ||
{ | ||
name = "www" | ||
type = "A" | ||
ttl = 3600 | ||
records = [ | ||
"127.0.0.1", | ||
] | ||
}, | ||
] | ||
) | ||
} | ||
module "vpce" { | ||
source = "git::git::https://github.com/UKHomeOffice/core-cloud-vpc-endpoint-tf-module.git?ref=main" | ||
vpc_endpoint_name = "some_service" | ||
vpc_id = "vpc-xxxxxxxxxxxxxxxxx" | ||
service_name = "com.amazonaws.vpce.<region>.xxxxxxxxxxxxxxx" | ||
security_group_ids = ["sg-xxxxxxxxxxxxxx"] | ||
subnet_ids = ["subnet-axxxxxxxxx", "subnet-bxxxxxxxxx", "subnet-cxxxxxxxx"] | ||
managed_private_dns_enabled = false | ||
custom_private_r53_zone = "private.example.com" | ||
} | ||
``` | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 | | ||
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 5.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 5.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_records"></a> [records](#module\_records) | terraform-aws-modules/route53/aws//modules/records | ~> 4 | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [aws_route53_zone.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_r53_records_as_json"></a> [r53\_records\_as\_json](#input\_r53\_records\_as\_json) | A JSON encoded String of the records for the Route53 Zone you wish to create, please see example for usage. It's JSON encoded due to Terragrunt Bug - https://github.com/gruntwork-io/terragrunt/issues/1211 | `string` | n/a | yes | | ||
| <a name="input_r53_zone"></a> [r53\_zone](#input\_r53\_zone) | The name of the Route53 Zone. e.g example.com | `string` | n/a | yes | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no | | ||
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | A list of VPCs to associate the Route53 Zone with - setting this will create a Private Hosted Zone (PHZ) | `list(string)` | `[]` | no | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_aws_route53_record_fqdn"></a> [aws\_route53\_record\_fqdn](#output\_aws\_route53\_record\_fqdn) | n/a | | ||
| <a name="output_aws_route53_record_name"></a> [aws\_route53\_record\_name](#output\_aws\_route53\_record\_name) | n/a | | ||
| <a name="output_aws_route53_record_zone_id"></a> [aws\_route53\_record\_zone\_id](#output\_aws\_route53\_record\_zone\_id) | n/a | | ||
<!-- END_TF_DOCS --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
resource "aws_route53_zone" "this" { | ||
name = var.r53_zone | ||
|
||
dynamic "vpc" { | ||
for_each = toset(var.vpc_id) | ||
content { | ||
vpc_id = vpc.key | ||
} | ||
} | ||
tags = var.tags | ||
} | ||
|
||
module "records" { | ||
source = "terraform-aws-modules/route53/aws//modules/records" | ||
version = "~> 4" | ||
|
||
zone_id = aws_route53_zone.this.zone_id | ||
records_jsonencoded = var.r53_records_as_json | ||
|
||
depends_on = [aws_route53_zone.this] | ||
} |
11 changes: 11 additions & 0 deletions
11
modules/aws/networking/route53_zone_with_records/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
output "aws_route53_record_zone_id" { | ||
value = aws_route53_zone.this.zone_id | ||
} | ||
|
||
output "aws_route53_record_name" { | ||
value = module.records.route53_record_name | ||
} | ||
|
||
output "aws_route53_record_fqdn" { | ||
value = module.records.route53_record_fqdn | ||
} |
21 changes: 21 additions & 0 deletions
21
modules/aws/networking/route53_zone_with_records/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
variable "vpc_id" { | ||
description = "A list of VPCs to associate the Route53 Zone with - setting this will create a Private Hosted Zone (PHZ)" | ||
type = list(string) | ||
default = [] | ||
} | ||
|
||
variable "r53_zone" { | ||
description = "The name of the Route53 Zone. e.g example.com" | ||
type = string | ||
} | ||
|
||
variable "r53_records_as_json" { | ||
description = "A JSON encoded String of the records for the Route53 Zone you wish to create, please see example for usage. It's JSON encoded due to Terragrunt Bug - https://github.com/gruntwork-io/terragrunt/issues/1211" | ||
type = string | ||
} | ||
|
||
variable "tags" { | ||
description = "A map of tags to add to all resources" | ||
type = map(string) | ||
default = {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = "~> 5.0" | ||
} | ||
} | ||
required_version = ">= 1.0" | ||
} |