axecopfire
axecopfire

Reputation: 652

Amplify save environment variables to backend

Following the docs, I set my environment variable in the console ($CLIENT_ID). In the console I added the echo command to try and insert the variable into a .env.

The error I keep getting is There was an issue connecting to your repo provider. When I remove the echo line the build passes. I've tried single/double quotes and putting the line above/below the other lines under the build commands phase.

Here's the backend section for the build process.

backend:
  phases:
    build:
      commands:
        - echo 'CLIENT_ID=$CLIENT_ID' >> backend/.env
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple

Upvotes: 0

Views: 811

Answers (2)

Pablo LION
Pablo LION

Reputation: 1435

I wrote an comment but to make it easier, I quote from answers from this question

build:
      commands:
        - npm run build
        - VARIABLE_NAME_1=$VARIABLE_NAME_1 # it works like this
        - VARIABLE_NAME_2=${VARIABLE_NAME_2} # it also works this way

Please thumb up on the original answers, and flag this question as duplicated.

Upvotes: 1

axecopfire
axecopfire

Reputation: 652

Seems this is a feature request: https://github.com/aws-amplify/amplify-cli/issues/4347

Upvotes: 0

Related Questions