【问题标题】:Storing secrets into Bitbucket Pipelines and then deploy on App Engine?将机密存储到 Bitbucket Pipelines 中,然后在 App Engine 上部署?
【发布时间】:2020-04-09 14:09:33
【问题描述】:

假设在 bitbucket 存储库中有一个项目,将秘密 API 密钥存储在配置文件(如 config.json)中:

{
    "secret": 
}

是否可以从 bitbucket 管道中的变量中引用“秘密”变量,然后将其自动部署到 google App Engine,以便 App Engine“知道”秘密变量?

【问题讨论】:

    标签: javascript express bitbucket bitbucket-pipelines


    【解决方案1】:

    您可以在管道中使用envsubst 命令。

    您的 json 文件将如下所示并命名为 config_template.json:

    {
        "secret": $SECRET
    }
    

    管道中的步骤如下所示:

    - step:
        name: replace secret
        script:
          # pipe config_template.json to envsubst and store result in a file called config.json
          - cat config_template.json | envsubst > config.json
          # show config.json TODO: Remove this when you are sure it is working!
          - cat config.json
          # Deploy config.json to App Engine here!
    

    这假设您的构建映像中有envsubst,并且您的管道中有一个名为SECRET 的存储库变量。

    【讨论】:

    • 这样一来,App Engine 就不会持有原始密钥,对吗?
    • 我不明白你的意思,但你可以将你的bitbucket中的文件更改为config_template.json或其他东西,然后以config.json的身份上传到App Engine。我将相应地更新示例。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-09
    • 1970-01-01
    • 2021-02-22
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多