Implement day 2 in Terraform

This commit is contained in:
2024-12-02 18:25:01 +01:00
parent 5a9667094c
commit b2add928ad
6 changed files with 94 additions and 3 deletions

28
2024/bonus/day02/main.tf Normal file
View File

@@ -0,0 +1,28 @@
variable "input" {
type = string
}
locals {
reports = [for line in split("\n", trim(var.input, "\n")) : [for num in split(" ", line) : parseint(num, 10)]]
}
module "part1_valid" {
source = "./is_valid"
count = length(local.reports)
report = local.reports[count.index]
}
module "part2_valid" {
source = "./is_savable"
count = length(local.reports)
report = local.reports[count.index]
}
output "part1" {
value = length([for i in range(length(local.reports)) : true if module.part1_valid[i].valid])
}
output "part2" {
value = length([for i in range(length(local.reports)) : true if module.part2_valid[i].valid])
}