Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Variables within Environment Variables

With Matillion Version: 1.30.6 (build 85), is it possible to use a variable as part of the value of an Environment Variable?

With these settings

environment Text Global dev
test_var Text Global matillion-${environment}-environment

a python script prints the value of test_var as "matillion-${environment}-environment" and not "matillion-dev-environment".

3 Community Answers

Matillion Agent  

Ian Funnell —

Hi John,

No, this is not permitted. Instead, you can use different default values for each of the environments that you have created.

Please see this document for more information.

Best regards,
Ian


John Auld —

Please can you reconsider the use of variables in values.

Not being able to cannot follow DRY principals creates avoidable problems and opportunities to make mistakes.

Consider a situation where there are different sets of resources (e.g. S3 buckets) for each environment. it would be better to declare the environment name once per Matillion environment, as per the example above.

That way, I only need to check one variable to be sure that values are good.

With the current arrangement, I have to check all variables.


Matillion Agent  

Ian Funnell —

Hi John,

I agree with the principle of storing a value in only one place, and using your example the way we would do this in Matillion is to have one variable (e.g. named output_bucket) which has been given different default values for different environments. You’ll see in the Manage Environment Variables dialog there’s one column for every environment that you’ve declared.

Then, in your job you just use ${output_bucket} and if the job happens to be running in the Dev environment it will evaluate to s3://the-dev-bucket. If the job is being run in production then it will automatically default to s3://the-prod-bucket.

I’m sorry but I’m pretty sure we would not be able to change the way variables work (simple 1-level string replacement) anyway, because of the likely regression problems it would cause.

Best regards,
Ian

Post Your Community Answer

To add an answer please login