I’ve got a pipeline setup to build some AWS Infrastructure using terraform.
I need to set AWS_REGION as an environment variable, but if I do this in Project Settings > Environment Variables on the CircleCI console then I can’t read the value back.
So I had the idea that I could set it as a parameter in the config.yml file. Something like:
AWS_REGION=<< pipeline.parameters.aws_region >>
Then I could have aws_region default to my usual region, but override it in the job if I need to.
This seemed so simple, but I couldn’t see how to do this in the docs, and everything I try doesn’t work. I either get syntax errors or AWS_REGION is set literally to “<< pipeline.parameters.aws_region >>” which obviously causes terraform to explode.
I was wondering if anyone else has run into this problem, and if there’s any way around it?
Thanks. I’ve been trying to use the environment: command but I can’t get it to work. The variable doesn’t get set properly so the terraform command won’t run. This is different from the example, which only echoes a string to the screen.