Given this map of objects
old_dns = {
public = {
default = {
name = "public.default.com"
records = {
service1 = {
name = "service1"
type = "A"
ttl = 300
records = ["1.2.3.4"]
}
service2 = {
name = "service2"
type = "A"
ttl = 300
records = ["2.3.4.5"]
}
}
tags = {
foo = "bar"
}
}
}
private = {
default = {
name = "private.default.com"
records = {
service1 = {
name = "service1"
type = "A"
ttl = 300
records = ["1.2.3.4"]
}
service2 = {
name = "service2"
type = "A"
ttl = 300
records = ["2.3.4.5"]
}
}
tags = {
foo = "bar"
}
}
}
}
I want to insert this object into the records map in private:
new_public_record = {
service3 = {
name = "service3"
type = "A"
ttl = 300
records = ["3.4.5.6"]
}
}
I can’t quite get my head round the syntax needed in the locals block. Feels like something that might be done pretty easily with the .update() method in python - is reshaping the data with locals even a good idea? pretty frustrated with this