hello, need some help with syntax. i'm looking to ...
# atmos
b
hello, need some help with syntax. i'm looking to combine 2 tf outputs from separate components. something simliar to the below, which does not seem to work
Copy code
vars:
  connection_string: |
    printf "postgres://username:%s@%s:5432/dbname" 
      !terraform.output rds-postgres-resources .additional_users | .username.db_user_password
      !terraform.output rds-postgres rds_address
a
this is not supported directly b/c the
!terraform.output
(and
!terraform.state
) function is a YAML explicit tag, which has to be at the beginning of the string. You have two choices: • Update the Terraform component code to accept two vars and then combine them in terraform • Use [atmos.Component](https://atmos.tools/core-concepts/stacks/templates/functions/atmos.Component/) template functions and then combine the results using Go templates, e.g.
printf
b
thanks for the lead!
e
Also, our general recommendation is—if it's not too much work—making the module smarter to handle the concatenation and formatting.
👍 1
Rather than putting a lot of logic and formatting into the Atmos stack configuration itself.
That's not always an option when you are using third-party modules, for example—and that's the use case for doing what you're doing right now: concatenating strings in the stack configuration itself.
b
thats a good point. we're pulling in modules but we can always add an additional file for outputs which won't get overriden with component updater
e
Yes! Exactly... using the overrides pattern.
You can add variables, locals, outputs, etc.