Specifically for the rancher2_registry Resource, it has a registries argument that says it is a list but I can’t figure out how to populate it.
https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/registry
Here’s what the rancher2_registry looks like
# Create a new rancher2 Namespaced Registry
resource "rancher2_registry" "foo" {
name = "foo"
description = "Terraform registry foo"
project_id = "<project_id>"
namespace_id = "<namespace_id>"
registries {
address = "test.io"
username = "user2"
password = "pass"
}
}
My variable looks like this
variable "containerRepositories" {
type = list(object({
url = string
username = string
password = string
}))
default = []
description = "A list of Docker container repositories"
}
Here’s how I’m trying to do it, which is not correct.
# Add the customers Artifactory Docker registries as Rancher registries in case they want to load custom build images from one of them.
resource "rancher2_registry" "registry" {
count = length(var.containerRepositories) > 0 ? 1 : 0
name = "registry"
description = "Registry entry to talk to customers Artifactory Docker registries"
project_id = var.rancherProject
namespace_id = rancher2_namespace.jenkins-namespace.id
registries {
for auth in var.containerRepositories : auth => {
address = auth.url
username = auth.username
password = auth.password
}
}
}
Does anyone know how to accomplish this?