Skip to content

Commit

Permalink
Merge pull request #1 from clouddrove/simple
Browse files Browse the repository at this point in the history
Simple
  • Loading branch information
Nikita Dugar authored Nov 5, 2019
2 parents b09a435 + ea6950b commit 0f75198
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 194 deletions.
92 changes: 34 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


<h1 align="center">
Terraform AWS Route table
Terraform AWS Route53 Record
</h1>

<p align="center" style="font-size: 1.2rem;">
Expand All @@ -24,13 +24,13 @@
</p>
<p align="center">

<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-aws-route-table'>
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-aws-route53-record'>
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
</a>
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+AWS+Route+table&url=https://github.com/clouddrove/terraform-aws-route-table'>
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+AWS+Route53+Record&url=https://github.com/clouddrove/terraform-aws-route53-record'>
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
</a>
<a href='https://twitter.com/intent/tweet/?text=Terraform+AWS+Route+table&url=https://github.com/clouddrove/terraform-aws-route-table'>
<a href='https://twitter.com/intent/tweet/?text=Terraform+AWS+Route53+Record&url=https://github.com/clouddrove/terraform-aws-route53-record'>
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
</a>

Expand Down Expand Up @@ -65,59 +65,34 @@ This module has a few dependencies:
## Examples


**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-route-table/releases).
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-aws-route53-record/releases).


Here are some examples of how you can use this module in your inventory structure:
### Simple set
```hcl
module "route-table" {
record_enabled = true
zone_id = "Z2FDRFHATA1ER4"
names = [
"www.",
"admin."
]
types = [
"A",
"CNAME"
]
ttls = [
"3600",
"3600",
]
values = [
"10.0.0.27",
"mydomain.com",
]
module "route53-record" {
source = "git::https://github.com/clouddrove/terraform-aws-route53-record.git?ref=tags/0.12.1"
zone_id = "Z1XJD7SSBKXLC1"
name = "www"
type = "A"
ttl = "3600"
values = "10.0.0.27"
}
```

### Set with alias
```hcl
module "route-table" {
source = "git::https://github.com/clouddrove/terraform-aws-route-table.git?ref=tags/0.12.0"
record_enabled = true
zone_id = "Z2FDRFHATA1ER4"
names = [
"www.",
"admin."
]
types = [
"A",
"CNAME"
]
alias = {
names = [
"d130easdflja734js.cloudfront.net"
]
zone_ids = [
"Z2FDRFHATA1ER4"
]
evaluate_target_healths = [
false
]
}
module "route53-record" {
source = "git::https://github.com/clouddrove/terraform-aws-route53-record.git?ref=tags/0.12.1"
zone_id = "Z1XJD7SSBKXLC1"
name = "www."
type = "A"
alias = {
name = "d130easdflja734js.cloudfront.net"
zone_id = "Z2FDRFHATA1ER4"
evaluate_target_health = false
}
}
```

Expand All @@ -131,21 +106,22 @@ Here are some examples of how you can use this module in your inventory structur
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| alias | An alias block. Conflicts with ttl & records. Alias record documented below. | map | `<map>` | no |
| allow_overwrites | Allow creation of this record in Terraform to overwrite an existing record, if any. This does not affect the ability to update the record in Terraform and does not prevent other resources within Terraform or manual Route 53 changes outside Terraform from overwriting this record. false by default. This configuration is not recommended for most environments. | list | `<list>` | no |
| health_check_ids | The health check the record should be associated with. | list | `<list>` | no |
| multivalue_answer_routing_policies | Set to true to indicate a multivalue answer routing policy. Conflicts with any other routing policy. | list | `<list>` | no |
| names | The name of the record. | list | `<list>` | no |
| record_enabled | Whether to create Route53 record set. | bool | `false` | no |
| set_identifiers | Unique identifier to differentiate records with routing policies from one another. Required if using failover, geolocation, latency, or weighted routing policies documented below. | list | `<list>` | no |
| ttls | (Required for non-alias records) The TTL of the record. | list | `<list>` | no |
| types | The record type. Valid values are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT. | list | `<list>` | no |
| values | (Required for non-alias records) A string list of records. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add "" inside the Terraform configuration string (e.g. "first255characters""morecharacters"). | list | `<list>` | no |
| allow_overwrite | Allow creation of this record in Terraform to overwrite an existing record, if any. This does not affect the ability to update the record in Terraform and does not prevent other resources within Terraform or manual Route 53 changes outside Terraform from overwriting this record. false by default. This configuration is not recommended for most environments. | bool | `false` | no |
| health_check_id | The health check the record should be associated with. | string | `` | no |
| multivalue_answer_routing_policy | Set to true to indicate a multivalue answer routing policy. Conflicts with any other routing policy. | string | `` | no |
| name | The name of the record. | string | `` | no |
| record_enabled | Whether to create Route53 record set. | bool | `true` | no |
| set_identifier | Unique identifier to differentiate records with routing policies from one another. Required if using failover, geolocation, latency, or weighted routing policies documented below. | string | `` | no |
| ttl | (Required for non-alias records) The TTL of the record. | string | `` | no |
| type | The record type. Valid values are A, AAAA, CAA, CNAME, MX, NAPTR, NS, PTR, SOA, SPF, SRV and TXT. | string | `` | no |
| values | (Required for non-alias records) A string list of records. To specify a single record value longer than 255 characters such as a TXT record for DKIM, add "" inside the Terraform configuration string (e.g. "first255characters""morecharacters"). | string | `` | no |
| zone_id | Zone ID. | string | `` | no |


## Feedback
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-route-table/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-aws-route53-record/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).

If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-route-table)!
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-aws-route53-record)!

## About us

Expand Down
63 changes: 19 additions & 44 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#

# Name of this project
name : Terraform AWS Route table
name : Terraform AWS Route53 Record

# License of this project
license: "MIT"

# Canonical GitHub repo
github_repo: clouddrove/terraform-aws-route-table
github_repo: clouddrove/terraform-aws-route53-record

# Badges to display
badges:
Expand All @@ -36,52 +36,27 @@ usage : |-
Here are some examples of how you can use this module in your inventory structure:
### Simple set
```hcl
module "route-table" {
record_enabled = true
zone_id = "Z2FDRFHATA1ER4"
names = [
"www.",
"admin."
]
types = [
"A",
"CNAME"
]
ttls = [
"3600",
"3600",
]
values = [
"10.0.0.27",
"mydomain.com",
]
module "route53-record" {
source = "git::https://github.com/clouddrove/terraform-aws-route53-record.git?ref=tags/0.12.1"
zone_id = "Z1XJD7SSBKXLC1"
name = "www"
type = "A"
ttl = "3600"
values = "10.0.0.27"
}
```
### Set with alias
```hcl
module "route-table" {
source = "git::https://github.com/clouddrove/terraform-aws-route-table.git?ref=tags/0.12.0"
record_enabled = true
zone_id = "Z2FDRFHATA1ER4"
names = [
"www.",
"admin."
]
types = [
"A",
"CNAME"
]
alias = {
names = [
"d130easdflja734js.cloudfront.net"
]
zone_ids = [
"Z2FDRFHATA1ER4"
]
evaluate_target_healths = [
false
]
}
module "route53-record" {
source = "git::https://github.com/clouddrove/terraform-aws-route53-record.git?ref=tags/0.12.1"
zone_id = "Z1XJD7SSBKXLC1"
name = "www."
type = "A"
alias = {
name = "d130easdflja734js.cloudfront.net"
zone_id = "Z2FDRFHATA1ER4"
evaluate_target_health = false
}
}
```
29 changes: 8 additions & 21 deletions _example/set-with-alias/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,15 @@ provider "aws" {
region = "eu-west-1"
}

module "route-table" {
source = "git::https://github.com/clouddrove/terraform-aws-route-table.git?ref=tags/0.12.0"
module "route53-record" {
source = "git::https://github.com/clouddrove/terraform-aws-route53-record.git?ref=tags/0.12.1"

zone_id = "Z2FDRFHATA1ER4"

names = [
"www.",
"admin."
]
types = [
"A",
"CNAME"
]
zone_id = "Z1XJD7SSBKXLC1"
name = "www"
type = "A"
alias = {
names = [
"d130easdflja734js.cloudfront.net"
]
zone_ids = [
"Z2FDRFHATA1ER4"
]
evaluate_target_healths = [
false
]
name = "d130easdflja734js.cloudfront.net"
zone_id = "Z2FDRFHATA1ER4"
evaluate_target_health = false
}
}
9 changes: 0 additions & 9 deletions _example/set-with-alias/outputs.tf

This file was deleted.

26 changes: 7 additions & 19 deletions _example/simple-set/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,12 @@ provider "aws" {
region = "eu-west-1"
}

module "route-table" {
source = "git::https://github.com/clouddrove/terraform-aws-route-table.git?ref=tags/0.12.0"
module "route53-record" {
source = "git::https://github.com/clouddrove/terraform-aws-route53-record.git?ref=tags/0.12.1"

zone_id = "Z3XYSELRQ8JFS"
names = [
"www.",
"admin."
]
types = [
"A",
"CNAME"
]
ttls = [
"3600",
"3600",
]
values = [
"10.0.0.27",
"mydomain.com",
]
zone_id = "Z1XJD7SSBKXLC1"
name = "www"
type = "A"
ttl = "3600"
values = "10.0.0.27"
}
Empty file removed _example/simple-set/outputs.tf
Empty file.
38 changes: 19 additions & 19 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
# Module : Route53 Record Set
# Description : Terraform module to create Route53 record sets resource on AWS.
resource "aws_route53_record" "default" {
count = var.record_enabled && length(var.ttls) > 0 ? length(var.ttls) : 0
count = var.record_enabled && length(var.alias) == 0 ? 1 : 0
zone_id = var.zone_id
name = element(var.names, count.index)
type = element(var.types, count.index)
ttl = element(var.ttls, count.index)
records = split(",", element(var.values, count.index))
set_identifier = length(var.set_identifiers) > 0 ? element(var.set_identifiers, count.index) : ""
health_check_id = length(var.health_check_ids) > 0 ? element(var.health_check_ids, count.index) : ""
multivalue_answer_routing_policy = length(var.multivalue_answer_routing_policies) > 0 ? element(var.multivalue_answer_routing_policies, count.index) : null
allow_overwrite = length(var.allow_overwrites) > 0 ? element(var.allow_overwrites, count.index) : false
name = var.name
type = var.type
ttl = var.ttl
records = split(",", var.values)
set_identifier = var.set_identifier
health_check_id = var.health_check_id
multivalue_answer_routing_policy = var.multivalue_answer_routing_policy
allow_overwrite = var.allow_overwrite
}

# Module : Route53 Record Set
# Description : Terraform module to create Route53 record sets resource on AWS.
resource "aws_route53_record" "alias" {
count = var.record_enabled && length(var.alias) > 0 && length(var.alias["names"]) > 0 ? length(var.alias["names"]) : 0
count = var.record_enabled && length(var.alias) > 0 ? 1 : 0
zone_id = var.zone_id
name = element(var.names, count.index)
type = element(var.types, count.index)
set_identifier = length(var.set_identifiers) > 0 ? element(var.set_identifiers, count.index) : ""
health_check_id = length(var.health_check_ids) > 0 ? element(var.health_check_ids, count.index) : ""
multivalue_answer_routing_policy = length(var.multivalue_answer_routing_policies) > 0 ? element(var.multivalue_answer_routing_policies, count.index) : null
allow_overwrite = length(var.allow_overwrites) > 0 ? element(var.allow_overwrites, count.index) : false
name = var.name
type = var.type
set_identifier = var.set_identifier
health_check_id = var.health_check_id
multivalue_answer_routing_policy = var.multivalue_answer_routing_policy
allow_overwrite = var.allow_overwrite
alias {
name = length(var.alias) > 0 ? element(var.alias["names"], count.index) : ""
zone_id = length(var.alias) > 0 ? element(var.alias["zone_ids"], count.index) : ""
evaluate_target_health = length(var.alias) > 0 ? element(var.alias["evaluate_target_healths"], count.index) : false
name = var.alias["name"]
zone_id = var.alias["zone_id"]
evaluate_target_health = var.alias["evaluate_target_health"]
}
}
Loading

0 comments on commit 0f75198

Please sign in to comment.