Dynatrace/dynatrace-configuration-as-code

Use environment-name as parameter in the yaml or json

heydenb opened this issue · 5 comments

Is it possible to use the environment name as variable.
It is passed to monaco via "-s" and described in the environments.yaml
If so, what is the correct notation. I don't find it in the docs.
If not, this would be an interesting feature for us since our monaco envs match the name of the management zones and the environment tag.

Hi @heydenb.
Currently it is not possible to reference an environment name as a variable.
But we will keep this as an enhancement request (thanks for already labeling it 👍)

How would you expect this to behave if no specific-environment is selected?
I would imagine something like a .global.currentEnvironment variable that would contain the name of the environment that the config is being deployed to. Is that what you'd expect too?

Yes, something like that. If no specific env is selected I presume that monaco sequentially walks over all configured envs to push the update. At that moment it knows which env it is processing, right ;-)

+1
Monaco promises to allow us to apply config changes to multiple tenants but sometimes the content of those changes can vary between tenants - for example the DNS name of a service may differ between test and production or the recipients of an alert may vary.

I can see several possible ways to allow this with different pros and cons...

  1. Pass just the env name... then I think the template would need to contain 'if' logic based on the env
  2. Allow config values to be specified in the manifest yaml in a similar manner to the config yaml
  3. Allow the config values in the config yaml to be specified as a map using the env name as the key

Hi @andycarlsonbt,

I might be misunderstanding your issue, but I think you're asking for something else than described here.

Overwriting variables (or the JSON template that is being used) per environment is a standard feature of monaco.

Here are the docs for 2.x: https://www.dynatrace.com/support/help/manage/configuration-as-code/configuration/yaml-configuration#overriding-configuration-per-environment
and here for 1.x: https://dynatrace.github.io/dynatrace-configuration-as-code/configuration/yaml_config#specific-configuration-per-environment-or-group

What was asked for here is to use the environment name within configuration, which is not currently possible

Thanks, I hadn't spotted the section on environment overrides. I'll give that a try.