-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
482 additions
and
53 deletions.
There are no files selected for viewing
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,44 @@ | ||
| formatter: markdown table | ||
|
|
||
| header-from: main.tf | ||
| footer-from: "" | ||
|
|
||
| sections: | ||
| ## hide: [] | ||
| show: | ||
| - data-sources | ||
| - header | ||
| - footer | ||
| - inputs | ||
| - modules | ||
| - outputs | ||
| - providers | ||
| - requirements | ||
| - resources | ||
|
|
||
| output: | ||
| file: README.md | ||
| mode: inject | ||
| template: |- | ||
| <!-- BEGIN_TF_DOCS --> | ||
| {{ .Content }} | ||
| <!-- END_TF_DOCS --> | ||
| ## output-values: | ||
| ## enabled: false | ||
| ## from: "" | ||
| ## | ||
| ## sort: | ||
| ## enabled: true | ||
| ## by: name | ||
| ## | ||
| ## settings: | ||
| ## anchor: true | ||
| ## color: true | ||
| ## default: true | ||
| ## description: false | ||
| ## escape: true | ||
| ## indent: 2 | ||
| ## required: true | ||
| ## sensitive: true | ||
| ## type: true |
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,66 @@ | ||
| <!-- BEGIN_TF_DOCS --> | ||
| ## Requirements | ||
|
|
||
| No requirements. | ||
|
|
||
| ## Providers | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="provider_aws"></a> [aws](#provider\_aws) | n/a | | ||
| | <a name="provider_external"></a> [external](#provider\_external) | n/a | | ||
|
|
||
| ## Modules | ||
|
|
||
| No modules. | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [aws_cloudwatch_log_group.dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource | | ||
| | [aws_route53_record.inbound_a](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | ||
| | [aws_route53_record.inbound_ptr](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | ||
| | [aws_route53_record.outbound_a](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | ||
| | [aws_route53_record.outbound_ptr](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_record) | resource | | ||
| | [aws_route53_resolver_endpoint.inbound](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_endpoint) | resource | | ||
| | [aws_route53_resolver_endpoint.outbound](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_endpoint) | resource | | ||
| | [aws_route53_resolver_query_log_config.dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_query_log_config) | resource | | ||
| | [aws_route53_resolver_query_log_config_association.dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_query_log_config_association) | resource | | ||
| | [aws_route53_resolver_rule.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule) | resource | | ||
| | [aws_route53_resolver_rule.amazon](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule) | resource | | ||
| | [aws_route53_resolver_rule.reverse](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule) | resource | | ||
| | [aws_route53_resolver_rule_association.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule_association) | resource | | ||
| | [aws_route53_resolver_rule_association.amazon](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule_association) | resource | | ||
| | [aws_route53_resolver_rule_association.reverse](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_resolver_rule_association) | resource | | ||
| | [aws_route53_zone.domain_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource | | ||
| | [aws_route53_zone.ptr_zone](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource | | ||
| | [aws_security_group.sg1](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group) | resource | | ||
| | [aws_subnet.endpoints](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet) | data source | | ||
| | [aws_subnet_ids.endpoints](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source | | ||
| | [external_external.inbound_sorted](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source | | ||
| | [external_external.outbound_sorted](https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/external) | data source | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_application_tags"></a> [application\_tags](#input\_application\_tags) | Default application tags to be used on non-infrastructure resources | `map(string)` | `{}` | no | | ||
|
|
||
| ## Outputs | ||
|
|
||
| | Name | Description | | ||
| |------|-------------| | ||
| | <a name="output_all_zones"></a> [all\_zones](#output\_all\_zones) | DNS zone list | | ||
| | <a name="output_domain_zone_id"></a> [domain\_zone\_id](#output\_domain\_zone\_id) | DICE development DNS Zone ID | | ||
| | <a name="output_domain_zone_ns"></a> [domain\_zone\_ns](#output\_domain\_zone\_ns) | DICE development DNS Zone Nameservers | | ||
| | <a name="output_inbound_dns"></a> [inbound\_dns](#output\_inbound\_dns) | DNS entries for inbound DNS resolver | | ||
| | <a name="output_inbound_dns_map"></a> [inbound\_dns\_map](#output\_inbound\_dns\_map) | DNS entries for inbound DNS resolver name and IP only | | ||
| | <a name="output_outbound_dns"></a> [outbound\_dns](#output\_outbound\_dns) | DNS entries for outbound DNS resolver | | ||
| | <a name="output_ptr_zone_id"></a> [ptr\_zone\_id](#output\_ptr\_zone\_id) | DICE development DNS PTR Zone IDs | | ||
| | <a name="output_ptr_zone_info"></a> [ptr\_zone\_info](#output\_ptr\_zone\_info) | DICE development DNS PTR Zone Info | | ||
| | <a name="output_ptr_zone_ns"></a> [ptr\_zone\_ns](#output\_ptr\_zone\_ns) | DICE development DNS PTR Zone Nameservers | | ||
| | <a name="output_resolver_endpoint_info"></a> [resolver\_endpoint\_info](#output\_resolver\_endpoint\_info) | DNS Resolver Endpoint Information | | ||
| | <a name="output_sg_sg1_arn"></a> [sg\_sg1\_arn](#output\_sg\_sg1\_arn) | DNS Seurity group ARN | | ||
| | <a name="output_sg_sg1_id"></a> [sg\_sg1\_id](#output\_sg\_sg1\_id) | DNS Seurity group ID | | ||
| <!-- END_TF_DOCS --> |
File renamed without changes.
File renamed without changes.
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,13 @@ | ||
| locals { | ||
| base_tags = { | ||
| "boc:created_by" = "terraform" | ||
| } | ||
| } | ||
|
|
||
| locals { | ||
| vpc_info = data.terraform_remote_state.vpc_east_vpc4.outputs.vpc_info | ||
| vpc_id = local.vpc_info["vpc_id"] | ||
| domain_name = local.vpc_info["vpc_domain_name"] | ||
| dns_servers = local.vpc_info["vpc_dns_servers"] | ||
| vpc_short_name = local.vpc_info["vpc_short_name"] | ||
| } |
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
| locals { | ||
| region = var.region | ||
| } |
File renamed without changes.
File renamed without changes.
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,19 @@ | ||
| #!/bin/env python | ||
|
|
||
| import json | ||
| import sys | ||
| import ipaddress | ||
|
|
||
| r=0 | ||
| outdata={'ip_addresses_sorted':''} | ||
| try: | ||
| indata=json.load(sys.stdin) | ||
| ipa=indata['ip_addresses'].split(',') | ||
| ips=sorted(ipa,key=ipaddress.ip_address) | ||
| outdata['ip_addresses_sorted']=','.join(ips) | ||
| print(json.dumps(outdata)) | ||
| except: | ||
| sys.stderr.write("unable to parse input address\n") | ||
| r=1 | ||
|
|
||
| sys.exit(r) |
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,7 @@ | ||
| COMMAND tf-directory-setup.py -l none -f | ||
| COMMAND tf-init -upgrade | ||
| COMMAND mv records.tf records.tf.later | ||
| ALL | ||
| COMMAND mv records.tf.later records.tf | ||
| ALL | ||
| COMMAND tf-directory-setup.py -l s3 |
File renamed without changes.
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,104 @@ | ||
| locals { | ||
| # calculate set of /24 blocks for PTR subnets from cidr bock size | ||
| vpc_cidr_block = local.vpc_info["vpc_cidr_block"] | ||
| bits = tonumber(split("/", local.vpc_cidr_block)[1]) | ||
| split_bits = 24 - local.bits | ||
| _ptr_zones = local.split_bits > 0 ? { for x in range(0, pow(2, local.split_bits)) : x => cidrsubnet(local.vpc_cidr_block, local.split_bits, x) } : {} | ||
| ptr_zones = { for x, s in local._ptr_zones : s => { | ||
| index = x | ||
| cidr = s | ||
| octets = split(".", split("/", s)[0]) | ||
| bits = tonumber(split("/", s)[1]) | ||
| ptr_zone = format("%v.in-addr.arpa", join(".", reverse(slice(split(".", split("/", s)[0]), 0, 3)))) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #--- | ||
| # domain (forward) zone | ||
| #--- | ||
| resource "aws_route53_zone" "domain_zone" { | ||
| name = local.domain_name | ||
| comment = "DICE development DNS Zone" | ||
| force_destroy = false | ||
|
|
||
| vpc { | ||
| vpc_id = local.vpc_id | ||
| vpc_region = local.region | ||
| } | ||
|
|
||
| # lifecycle { | ||
| # ignore_changes | ||
| # } | ||
|
|
||
| tags = merge( | ||
| local.base_tags, | ||
| local.common_tags, | ||
| var.application_tags, | ||
| tomap({ "Name" = local.domain_name }), | ||
| ) | ||
| } | ||
| #resource "aws_route53_zone_association" "dns_zone" { } | ||
|
|
||
| output "domain_zone_id" { | ||
| description = "DICE development DNS Zone ID" | ||
| value = aws_route53_zone.domain_zone.zone_id | ||
| } | ||
|
|
||
| output "domain_zone_ns" { | ||
| description = "DICE development DNS Zone Nameservers" | ||
| value = aws_route53_zone.domain_zone.name_servers | ||
| } | ||
|
|
||
| #--- | ||
| # ptr (reverse) zones | ||
| #--- | ||
| resource "aws_route53_zone" "ptr_zone" { | ||
| for_each = local.ptr_zones | ||
|
|
||
| name = each.value.ptr_zone | ||
| comment = format("DICE development DNS PTR Zone %v (%v)", each.value.ptr_zone, each.value.cidr) | ||
| force_destroy = false | ||
|
|
||
| vpc { | ||
| vpc_id = local.vpc_id | ||
| vpc_region = local.region | ||
| } | ||
|
|
||
| # lifecycle { | ||
| # ignore_changes | ||
| # } | ||
|
|
||
| tags = merge( | ||
| local.base_tags, | ||
| local.common_tags, | ||
| var.application_tags, | ||
| tomap({ "Name" = each.value.ptr_zone }), | ||
| ) | ||
| } | ||
|
|
||
|
|
||
| output "ptr_zone_id" { | ||
| description = "DICE development DNS PTR Zone IDs" | ||
| value = { for x, s in local.ptr_zones : x => aws_route53_zone.ptr_zone[x].zone_id } | ||
| } | ||
|
|
||
| output "ptr_zone_ns" { | ||
| description = "DICE development DNS PTR Zone Nameservers" | ||
| value = { for x, s in local.ptr_zones : x => aws_route53_zone.ptr_zone[x].name_servers } | ||
| } | ||
|
|
||
| output "ptr_zone_info" { | ||
| description = "DICE development DNS PTR Zone Info" | ||
| value = { for x, s in local.ptr_zones : x => { | ||
| cidr = s.cidr | ||
| ptr_zone = s.ptr_zone | ||
| zone_id = aws_route53_zone.ptr_zone[x].zone_id | ||
| name_servers = aws_route53_zone.ptr_zone[x].name_servers | ||
| } } | ||
| } | ||
|
|
||
| output "all_zones" { | ||
| description = "DNS zone list" | ||
| value = flatten(concat([local.domain_name], [for x, s in local.ptr_zones : s.ptr_zone])) | ||
| } |
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
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,25 @@ | ||
| ## locals { | ||
| ## reverse_zones = flatten([ | ||
| ## "10.in-addr.arpa", | ||
| ## "168.192.in-addr.arpa", | ||
| ## "129.148.in-addr.arpa", | ||
| ## [for x in range(16, 32) : format("%v.172.in-addr.arpa", x)], | ||
| ## ]) | ||
| ## reverse_rules = formatlist("reverse-%v", local.reverse_zones) | ||
| ## forward_rules = ["forward-all-onprem", "amazon"] | ||
| ## all_main_rules = formatlist("resolver-%v", concat(local.forward_rules, local.reverse_rules)) | ||
| ## } | ||
|
|
||
| data "aws_route53_resolver_rules" "all_rules" { | ||
| share_status = "SHARED_WITH_ME" | ||
| } | ||
|
|
||
| data "aws_route53_resolver_rules" "all_rules_me" { | ||
| share_status = "SHARED_BY_ME" | ||
| } | ||
|
|
||
| resource "aws_route53_resolver_rule_association" "all_rules" { | ||
| for_each = length(data.aws_route53_resolver_rules.all_rules.resolver_rule_ids) > 0 ? toset(data.aws_route53_resolver_rules.all_rules.resolver_rule_ids) : toset(data.aws_route53_resolver_rules.all_rules_me.resolver_rule_ids) | ||
| resolver_rule_id = each.key | ||
| vpc_id = local.vpc_id | ||
| } |
Oops, something went wrong.