Skip to content

Commit c88d5bc

Browse files
1david5cloudpossebotkorenyoni
authored
Fix: create records using for_each instead of count (#37)
* create records using for_each instead of count * Update contributors list. Co-authored-by: cloudpossebot <11232728+cloudpossebot@users.noreply.github.com> Co-authored-by: Yonatan Koren <me@yonatankoren.com>
1 parent 8d0a211 commit c88d5bc

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
342342
### Contributors
343343

344344
<!-- markdownlint-disable -->
345-
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] |
346-
|---|---|---|---|
345+
| [![Erik Osterman][osterman_avatar]][osterman_homepage]<br/>[Erik Osterman][osterman_homepage] | [![Igor Rodionov][goruha_avatar]][goruha_homepage]<br/>[Igor Rodionov][goruha_homepage] | [![Andriy Knysh][aknysh_avatar]][aknysh_homepage]<br/>[Andriy Knysh][aknysh_homepage] | [![Vladimir][SweetOps_avatar]][SweetOps_homepage]<br/>[Vladimir][SweetOps_homepage] | [![1david5][1david5_avatar]][1david5_homepage]<br/>[1david5][1david5_homepage] | [![Yonatan Koren][korenyoni_avatar]][korenyoni_homepage]<br/>[Yonatan Koren][korenyoni_homepage] |
346+
|---|---|---|---|---|---|
347347
<!-- markdownlint-restore -->
348348

349349
[osterman_homepage]: https://github.com/osterman
@@ -354,6 +354,10 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
354354
[aknysh_avatar]: https://img.cloudposse.com/150x150/https://github.com/aknysh.png
355355
[SweetOps_homepage]: https://github.com/SweetOps
356356
[SweetOps_avatar]: https://img.cloudposse.com/150x150/https://github.com/SweetOps.png
357+
[1david5_homepage]: https://github.com/1david5
358+
[1david5_avatar]: https://img.cloudposse.com/150x150/https://github.com/1david5.png
359+
[korenyoni_homepage]: https://github.com/korenyoni
360+
[korenyoni_avatar]: https://img.cloudposse.com/150x150/https://github.com/korenyoni.png
357361

358362
[![README Footer][readme_footer_img]][readme_footer_link]
359363
[![Beacon][beacon]][website]

README.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ contributors:
7373
github: "aknysh"
7474
- name: "Vladimir"
7575
github: "SweetOps"
76+
- name: "1david5"
77+
github: "1david5"
78+
- name: "Yonatan Koren"
79+
github: "korenyoni"

main.tf

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

88
resource "aws_route53_record" "default" {
9+
for_each = module.this.enabled ? toset(compact(var.aliases)) : []
910
#bridgecrew:skip=BC_AWS_NETWORKING_60:All of the aliases are configurable via var.aliases and it is the user's responsibility to ensure that all of the resources are in the same account.
1011
#bridgecrew:skip=BC_AWS_GENERAL_95:All of the aliases are configurable via var.aliases and it is the user's responsibility to ensure that all of the aliases point to resources and not just IPv4 addresses.
11-
count = module.this.enabled ? length(compact(var.aliases)) : 0
1212
zone_id = try(data.aws_route53_zone.default[0].zone_id, "")
13-
name = compact(var.aliases)[count.index]
13+
name = each.key
1414
allow_overwrite = var.allow_overwrite
1515
type = "A"
1616

@@ -22,9 +22,9 @@ resource "aws_route53_record" "default" {
2222
}
2323

2424
resource "aws_route53_record" "ipv6" {
25-
count = module.this.enabled && var.ipv6_enabled ? length(compact(var.aliases)) : 0
25+
for_each = module.this.enabled && var.ipv6_enabled ? toset(compact(var.aliases)) : []
2626
zone_id = try(data.aws_route53_zone.default[0].zone_id, "")
27-
name = compact(var.aliases)[count.index]
27+
name = each.key
2828
allow_overwrite = var.allow_overwrite
2929
type = "AAAA"
3030

outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
output "hostnames" {
2-
value = aws_route53_record.default.*.fqdn
2+
value = try([for alias in var.aliases : aws_route53_record.default[alias].fqdn], [])
33
description = "List of DNS records"
44
}
55

0 commit comments

Comments
 (0)