You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be dramatically easier to DRY up k8s templates while implicitly ordering the resource DAG if every k8s resource had a "name" attribute. As-is, we can extract the name attribute by using coalesce(kubernetes_manifest.my_manifest.metadata[*].name...), but that's an awfully complicated way to access such a commonly-used attribute.
Potential Terraform Configuration
resource"kubernetes_namespace""my_ns" {
metadata {
name ="my-namespace"
}
}
# proposed option: name attributeresource"kubernetes_secret""secret_0" {
metadata {
name ="secret-0"
namespace = kubernetes_namespace.my_ns.name
}
data = {
foo ="bar"
}
}
# current option #1: use coalesceresource"kubernetes_secret""secret_1" {
metadata {
name ="secret-1"
namespace =coalesce(kubernetes_namespace.my_ns.metadata[*].name...)
}
data = {
foo ="bar"
}
}
# current option #2: use depends_onresource"kubernetes_secret""secret_2" {
depends_on = [kubernetes_namespace.my_ns]
metadata {
name ="secret-2"
namespace ="my-namespace"
}
data = {
foo ="bar"
}
}
Community Note
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
If you are interested in working on this issue or have submitted a pull request, please leave a comment
The text was updated successfully, but these errors were encountered:
Hi @Manbeardo, thanks for opening this issue.
A much simpler alternative to this would be setting the namespace without the coalesce function, and instead just referencing the name attribute in the metadata (metadata[0].name). Since name is the first and thus only attribute in the metadata this should always work.
Hope this helped!
Description
It would be dramatically easier to DRY up k8s templates while implicitly ordering the resource DAG if every k8s resource had a "name" attribute. As-is, we can extract the name attribute by using
coalesce(kubernetes_manifest.my_manifest.metadata[*].name...)
, but that's an awfully complicated way to access such a commonly-used attribute.Potential Terraform Configuration
Community Note
The text was updated successfully, but these errors were encountered: