Can Atmos support collecting different outputs acr...
# atmos
p
Can Atmos support collecting different outputs across stacks from particular component, and injecting them to another? For example: I am deploying Argo-CD once to management cluster. There can be potentially be X number of workload clusters (separate component). For Argo-CD I need to create secret on management cluster to make it aware of number of workload clusters that exists. terraform.state function at least can only get output of one component in current, or different stacks; not combine across range of stacks. How should I solve issue or collecting outputs and merging them? There’s plenty of potential use cases where this pattern emerges.
a
can you try using
locals
? https://atmos.tools/stacks/locals https://atmos.tools/stacks/locals#yaml-functions-in-locals (let me know how it goes and if you have any issues)
p
@Andriy Knysh (Cloud Posse) I sort of ended up with something like this :
Copy code
locals:
        workload_clusters:
          - name: cluster-workload
            type: gke
Copy code
external_clusters: !template |
          {{- $result := dict -}}
          {{- range .locals.workload_clusters -}}
            {{- $comp := atmos.Component .name $.stack -}}
            {{- $_ := set $result .name (dict
                "type" .type
                "endpoint" $comp.outputs.cluster_endpoint
                "ca_certificate" $comp.outputs.cluster_ca_certificate
                "labels" (dict "role" "workload")
            ) -}}
          {{- end -}}
          {{ toJson $result }}
There is an issue though: I do get error with file
components/terraform/cluster-workload/backend.tf.json
missing.
The error shows
atmos.Component
trying to find the component at
components/terraform/cluster-workload/
instead of resolving through
metadata.component
to
components/terraform/gcp/gke-cluster/
. This is a limitation of
atmos.Component
during template evaluation - it’s not resolving the inheritance chain.
My goal was to be able to collect all instances of gke-cluster, which there can be many. This did not seem to go do correct direction.
Hmmpf.. when running
atmos describe component cluster-workload -s mp-plat-gcp-eun1-test
the component_path is set correctly there:
Copy code
omponent_path: /Users/paveq/modernpath/live-infrastructure/components/terraform/gcp/gke-cluster
a
thanks, we'll take a look at this and fix it asap