0

我已经在 GCP 的 Secret manager 中存储了一个密钥,并且我尝试在其中使用该密钥,cloudbuild.yaml但每次出现此错误时:

ERROR: (gcloud.functions.deploy) argument --set-secrets: Secrets value configuration 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' [ 'projects/gcp-project/secrets/SECRETKEY/versions/latest' ]]

我的云构建文件如下所示:

steps:
  - id: installing-dependencies
    name: 'python'
    entrypoint: pip
    args: ["install", "-r", "src/requirements.txt", "--user"]

  - id: deploy-function
    name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
    args:
    - gcloud
    - functions
    - deploy
    - name_of_my_function
    - --region=us-central1
    - --source=./src
    - --trigger-topic=name_of_my_topic
    - --runtime=python37
    - --set-secrets=[ SECRETKEY = 'projects/gcp-project/secrets/SECRETKEY/versions/latest' ]
    waitFor: [ "installing-dependencies" ] 

我正在阅读文档,但我没有任何其他线索可以帮助我。

4

1 回答 1

0

正如 al-dann 所提到的,在 set-secret 行中不应该有任何空格,因为您可以在代码中看到文档 最终更正:

 --set-secrets=[SECRETKEY='projects/gcp-project/secrets/SECRETKEY/versions/latest']

有关更多信息,您可以参考stackoverflow 线程博客,其中对秘密管理器的简要信息进行了很好的解释。

于 2022-03-02T05:54:21.987 回答