Skip to content

Commit d13bc2d

Browse files
authored
Allow for allow_overwrite functionality (#21)
I want to manage some existing records with Terraform, so need this functionality which switches the action to an UPSERT, from CREATE.
1 parent 70d4bf5 commit d13bc2d

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ Available targets:
119119
| Name | Description | Type | Default | Required |
120120
|------|-------------|:----:|:-----:|:-----:|
121121
| aliases | List of aliases | list(string) | - | yes |
122+
| 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 |
122123
| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no |
123124
| evaluate_target_health | Set to true if you want Route 53 to determine whether to respond to DNS queries | bool | `false` | no |
124125
| ipv6_enabled | Set to true to enable an AAAA DNS record to be set as well as the A record | bool | `false` | no |
@@ -190,6 +191,10 @@ We deliver 10x the value for a fraction of the cost of a full-time engineer. Our
190191

191192
Join our [Open Source Community][slack] on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure.
192193

194+
## Discourse Forums
195+
196+
Participate in our [Discourse Forums][discourse]. Here you'll find answers to commonly asked questions. Most questions will be related to the enormous number of projects we support on our GitHub. Come here to collaborate on answers, find solutions, and get ideas about the products and services we value. It only takes a minute to get started! Just sign in with SSO using your GitHub account.
197+
193198
## Newsletter
194199

195200
Sign up for [our newsletter][newsletter] that covers everything on our technology radar. Receive updates on what we're up to on GitHub as well as awesome new projects we discover.
@@ -305,6 +310,7 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
305310
[testimonial]: https://cpco.io/leave-testimonial?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=testimonial
306311
[office_hours]: https://cloudposse.com/office-hours?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=office_hours
307312
[newsletter]: https://cpco.io/newsletter?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=newsletter
313+
[discourse]: https://ask.sweetops.com/?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=discourse
308314
[email]: https://cpco.io/email?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=email
309315
[commercial_support]: https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=commercial_support
310316
[we_love_open_source]: https://cpco.io/we-love-open-source?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-route53-alias&utm_content=we_love_open_source

docs/terraform.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| Name | Description | Type | Default | Required |
44
|------|-------------|:----:|:-----:|:-----:|
55
| aliases | List of aliases | list(string) | - | yes |
6+
| 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 |
67
| enabled | Set to false to prevent the module from creating any resources | bool | `true` | no |
78
| evaluate_target_health | Set to true if you want Route 53 to determine whether to respond to DNS queries | bool | `false` | no |
89
| ipv6_enabled | Set to true to enable an AAAA DNS record to be set as well as the A record | bool | `false` | no |

main.tf

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ data "aws_route53_zone" "default" {
66
}
77

88
resource "aws_route53_record" "default" {
9-
count = var.enabled ? length(compact(var.aliases)) : 0
10-
zone_id = data.aws_route53_zone.default[0].zone_id
11-
name = compact(var.aliases)[count.index]
12-
type = "A"
9+
count = var.enabled ? length(compact(var.aliases)) : 0
10+
zone_id = data.aws_route53_zone.default[0].zone_id
11+
name = compact(var.aliases)[count.index]
12+
allow_overwrite = var.allow_overwrite
13+
type = "A"
1314

1415
alias {
1516
name = var.target_dns_name
@@ -19,10 +20,11 @@ resource "aws_route53_record" "default" {
1920
}
2021

2122
resource "aws_route53_record" "ipv6" {
22-
count = var.enabled && var.ipv6_enabled ? length(compact(var.aliases)) : 0
23-
zone_id = data.aws_route53_zone.default[0].zone_id
24-
name = compact(var.aliases)[count.index]
25-
type = "AAAA"
23+
count = var.enabled && var.ipv6_enabled ? length(compact(var.aliases)) : 0
24+
zone_id = data.aws_route53_zone.default[0].zone_id
25+
name = compact(var.aliases)[count.index]
26+
allow_overwrite = var.allow_overwrite
27+
type = "AAAA"
2628

2729
alias {
2830
name = var.target_dns_name

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,9 @@ variable "ipv6_enabled" {
4848
default = false
4949
description = "Set to true to enable an AAAA DNS record to be set as well as the A record"
5050
}
51+
52+
variable "allow_overwrite" {
53+
type = bool
54+
default = false
55+
description = "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"
56+
}

0 commit comments

Comments
 (0)