I have a catalog I use everywhere but now I have a...
# atmos
p
I have a catalog I use everywhere but now I have a case where I need the catalog to be a bit different for qa and dev, is it possible to conditionally add an import or use a yaml function to match a value as if that is present then add xxxxx lines?
Copy code
components:
  terraform:
    functionappwindows:
      metadata:
        type: abstract
      vars:
          name: pepe
          # If is dev or QA add :
          ip_whitelist:
             - 2.2.2.2
             - 1.1.1.1
e
Are you aware of the the new atmos profiles feature?
Maybe this could be a use case for it
p
I remember there were conditional imports but I have not tried anything yet
e
I don't believe we implemented conditional imports
We support importing templates and those templates can had conditionals
Including tempting the yaml it self
We also support import wildcards
p
I can see how profiles could work but I'm using CP actions so my next question will be, is this implemented there?
e
But personally I disdain all forms of templating and always look for conventional ways to solve it
@Dan Miller (Cloud Posse) did we update them?
It's as simple as setting ATMOS_PROFILE
p
then I will have to modify my workflows to add that
which is ok
e
It addresses a whole class of problems. With this you can also ensure any other setting in atmos can vary, and everything is documented in the configs
Reducing hacks, config sprawl
…hopefully it's a 2 for 1
d
I'm not sure I understand the issue. If you want different variable in qa and dev but the same in the others, why not create a different catalog definition that inherits the defaults and adds to it?
Copy code
# catalog/functionappwindows/defaults.yaml
components:
  terraform:
    functionappwindows:
      vars:
        name: pepe
        # default values for your component
Copy code
# catalog/functionappwindows/nonprod.yaml
import:
- catalog/functionappwindows/defaults

components:
  terraform:
    # extends functionappwindows that's defined in catalog/functionappwindows/defaults
    functionappwindows:
      vars:
        # values that are unique for nonprod (dev and qa) 
        ip_whitelist:
          - 2.2.2.2
          - 1.1.1.1
then in dev and qa import the nonprod archetype
Copy code
# stacks/orgs/acme/dev
# stacks/orgs/acme/qa
import:
- catalog/functionappwindows/nonprod
and in prod just import the default (or create a prod catalog)
Copy code
# stacks/orgs/acme/prod
import:
- catalog/functionappwindows/prod
OR
- catalog/functionappwindows/defaults
p
Ahhh true I could do that easy if we were talking of one monorepo, but that change will mean 34 PRs to my service repos
The catalog is held in the IAC monorepo, the service vendor files from it