I am using bbrun to simulate the pipeline run locally. Essentially what I need (not the issue) is to automate terragrunt deployment of an infrastructure on GCP. So every time it's pushed with a tag it deploys a certain environment.
This is my bitbucket-pipelines.yml (simplified for bbrun):
image: alpine/terragrunt:latest
definitions:
steps:
- step: &terragrunt
name: run terragrunt
script:
- cd ./env/dev
- terragrunt validate-all
pipelines:
default:
- step: *terragrunt
And everything works when I run this with bbrun when I have a credentials.json file (which is in /env/dev) that has a hardcoded secretes in it. So how can I add variables to the credentials.json file so that pipelines knows that there is a variable in that file?
For instance if I add a secrete variable in bitbucket-piplines console PRIVATE_KEY I want terragrunt to read this line
"private_key": "-----BEGIN PRIVATE KEY-----\${env:PRIVATE_KEY}\n-----END PRIVATE KEY-----\n",
#I also tried $PRIVATE_KEY and ${PRIVATE_KEY} when running bbrun with -e PRIVATE_KEY=***
in credentials.json as a value of the variable.
I am not sure if bbrun is just wrong here and bitbucket pipelines would actually pass the variables value but I get this error when running with variables:
Error: Error in function call
---
Call to function "jsondecode" failed: invalid character '$' in string escape
code.
I also tired adding:
variables:
PRIVATE_KEY_ID: $PRIVATE_KEY_ID
PRIVATE_KEY: $PRIVATE_KEY
Didn't work.
I also tried editing the file the the step script with envsubst command which works but this seems kinda dumb to use.