【发布时间】:2021-08-29 22:12:27
【问题描述】:
我有一个云函数,我想使用 Cloud Build 在我的 CD 管道中部署它。该函数需要存储在 Secret Manager 中的几个秘密,我想使用 --set-secrets 标志将它们作为环境变量拉入。
当我使用 CLI 手动部署时,我没有问题:
gcloud beta functions deploy myfunction \
--source src \
--trigger-topic mytopic \
--region europe-west1 \
--runtime python39 \
--set-secrets 'env_1=secret_1:latest','env_2=secret_2:latest'
但是,当我尝试使用具有此配置的 Cloud Build 进行部署时:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- beta
- functions
- deploy
- myfunction
- --source=src
- --trigger-topic=mytopic
- --region=europe-west1
- --runtime=python39
- --set-secrets='env_1=secret_1:latest','env_2=secret_2:latest'
我收到--set-secrets 参数must match the pattern 'SECRET:VERSION' or 'projects/{PROJECT}/secrets/{SECRET}:{VERSION}' or 'projects/{PROJECT}/secrets/{SECRET}/versions/{VERSION}' where VERSION is a number or the label 'latest' 的错误。我不明白为什么会出现此错误,因为我认为我的论点符合上述模式。
我有什么遗漏吗?
【问题讨论】:
-
您可以尝试删除 set-secret args 中的简单引号吗?
-
谢谢,这确实是解决方案!
标签: google-cloud-platform google-cloud-functions google-cloud-build