By using AWS re:Post, you agree to the Terms of Use

Trying to use environment variables

0

I am trying to follow the directions here https://docs.aws.amazon.com/amplify/latest/userguide/environment-variables.html, and the instructions say to add :$BUILD_ENV as follows:

build:
commands:
- npm run build:$BUILD_ENV

But this generates a syntax error saying "command build: not found". What I want to do is pass my Cognito API keys as environment variables, so I don't have to put them in my code.

Thanks for any help with this,
Lee

asked 2 years ago51 views
1 Answer
0

Hello, we have provided a general way for you to access environment variables. In your case, you might need to do something like:

build:
   commands:
      - ENV_NAME=$ENV_NAME
      - npm run build
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions