Reputation: 5461
How can I import a json file into Google Cloud Composer using command line?
I tried the below command
gcloud composer environments run comp-env --location=us-central1 variables -- --import composer_variables.json
I am getting the below error
[2019-01-17 13:34:54,003] {configuration.py:389} INFO - Reading the config from /etc/airflow/airflow.cfg
[2019-01-17 13:34:54,117] {app.py:44} WARNING - Using default Composer Environment Variables. Overrides have not been applied.
Missing variables file.
But when I set a single variable using below command it works fine.
gcloud composer environments run comp-env --location=us-central1 variables -- --set variable_name variable_value
Since I have more than 75 variables to be imported, we need to import it using json file. Please help me to resolve this issue
Upvotes: 6
Views: 6904
Reputation: 691
The follow command gcloud composer environments run {environment-name} variables -- --i {path-to-json-file}
executes airflow variables
remotely inside the Airflow containes. Hence the json file needs to be accessible within the Airflow worker/scheduler pod. So you'll need to copy your var.json
to GCS first and then run the command. For example:
gcloud composer environments storage data import --source=your-var.json --environment={environment-name} --location={location}
gcloud composer environments run {environment-name} --location={location} variables -- --i /home/airflow/gcs/data/your-var.json
.Upvotes: 13