What is the syntax to parse an S3 .json file into individual environment variables in the Serverless.ts configuration?
I’ve tried the following without success to get the environment variable MY_SECRET set to the value of MY_SECRET in the bucket’s JSON.
functions: {
hello: {
environment: {
MY_SECRET: "${s3:my-config/services/test/support-portal-api.json}"
},
…this deploys but sets MY_SECRET to the entire contents of the JSON file
functions: {
hello: {
environment: {
MY_SECRET: JSON.parse("${s3:my-config/services/test/support-portal-api.json}").MY_SECRET
},
…this fails to deploy with :
SyntaxError: Unexpected token $ in JSON at position 0
at JSON.parse (<anonymous>)
What is the correct syntax? The documentation isn’t very clear. Please note this is a Typescript (Serverless.ts) file.