Skip to content

Commit

Permalink
Fix: create records using for_each instead of count (#37)
Browse files Browse the repository at this point in the history
* create records using for_each instead of count
* Update contributors list.

Co-authored-by: cloudpossebot <[email protected]>
Co-authored-by: Yonatan Koren <[email protected]>
  • Loading branch information
3 people authored Jan 27, 2022
1 parent 8d0a211 commit c88d5bc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ Check out [our other projects][github], [follow us on twitter][twitter], [apply
### Contributors

<!-- markdownlint-disable -->
| [![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] |
|---|---|---|---|
| [![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] |
|---|---|---|---|---|---|
<!-- markdownlint-restore -->

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

[![README Footer][readme_footer_img]][readme_footer_link]
[![Beacon][beacon]][website]
Expand Down
4 changes: 4 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,7 @@ contributors:
github: "aknysh"
- name: "Vladimir"
github: "SweetOps"
- name: "1david5"
github: "1david5"
- name: "Yonatan Koren"
github: "korenyoni"
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ data "aws_route53_zone" "default" {
}

resource "aws_route53_record" "default" {
for_each = module.this.enabled ? toset(compact(var.aliases)) : []
#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.
#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.
count = module.this.enabled ? length(compact(var.aliases)) : 0
zone_id = try(data.aws_route53_zone.default[0].zone_id, "")
name = compact(var.aliases)[count.index]
name = each.key
allow_overwrite = var.allow_overwrite
type = "A"

Expand All @@ -22,9 +22,9 @@ resource "aws_route53_record" "default" {
}

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

Expand Down
2 changes: 1 addition & 1 deletion outputs.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
output "hostnames" {
value = aws_route53_record.default.*.fqdn
value = try([for alias in var.aliases : aws_route53_record.default[alias].fqdn], [])
description = "List of DNS records"
}

Expand Down

0 comments on commit c88d5bc

Please sign in to comment.