You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I'm trying to build a pipeline to deploy our serverless architecture. Ideally I can right into a local .env file including all several secured environment variables. I'm assuming the entire docker image is flushed after the pipeline is done deploying so this is really not a security concern.
However, when I try to write into the file, all env vars write ok except the secured ones. Any idea how to make this work?
# setup local .env file
- touch .env
- echo "DEV_DB_DATABASE=$DEV_DB_DATABASE" >> .env
- echo "DEV_DB_USERNAME=$DEV_DB_USERNAME" >> .env
- echo "DEV_DB_PASSWORD=$DEV_DB_PASSWORD" >> .env
- echo "DEV_DB_HOST=$DEV_DB_HOST" >> .env
- echo "DB_LOGGING=true" >> .env
- echo "SLS_DEBUG=*" >> .env
Where ```$DEV_DB_PASSWORD``` is a secured variable.
Oh Yes. No errors. What actually happens is all the normal environment variables gets written as expected. The secured ones translate into the string itself,
so this line:
will show as the following line:
DEV_DB_DATABASE=<name of the db from the env var>
BUT this line:
will result in the following line literally:
I'm assuming this is some sort of a security mechanism to not 'log' the secured vars but I wonder if there's a way around it or if I'm just doing something wrong. Ideally we actually write the value of the secured vars into the same file so we can then use it in our deploys.
How are you verifying the contents of the file? If you're running "$ cat .env" (or something similar) within Pipelines, then we will be masking the variable when it is printing from the file. But it should still be in the file as the correct value.
I've tested out a similar example here:
The value of "$SECRET" is "cat". (When I do echo "$SECRET" | wc -m, there's is also a new line character which is why it's 4 and not 3).
Does any of that help?