LoginSignup
4
6

More than 5 years have passed since last update.

Google Cloud Functionsで環境変数を設定する

Last updated at Posted at 2018-08-21

https://cloud.google.com/functions/docs/env-var
上記リンクに書いてある通りなんですが、--set-env-vars--env-vars-fileのフラグを付けてdeployをする
ポイントはbetaを使うところ Cloud SDK 227.0.0 (2018-12-04)よりbetaが必要なくなった

$ gcloud functions deploy functionname --set-env-vars="env1"="value","env2"="value2" --source='https://source.developers.google.com/projects/hogehoge/repos/foo/moveable-aliases/branchname' --runtime=nodejs8 --trigger-http 

更新するときは--update-env-varsを使う。環境変数のみで良い

$ gcloud functions deploy functionname --update-env-vars="env1"="valu2","env2"="value3","env3"="value4"

確認にはdescribe

$ gcloud functions describe functionname | yq '.environmentVariables'
{
  "env": "value",
  "env2": "value2",
  "env3": "valu3"
}


4
6
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6