将秘密存储到 Bitbucket Pipelines 中然后部署到 App Engine 上?
Storing secrets into Bitbucket Pipelines and then deploy on App Engine?
假设在 bitbucket 存储库中有一个项目在配置文件中存储秘密 API 密钥,例如 config.json:
{
"secret":
}
是否可以从 bitbucket 管道中的变量中引用 "secret" 变量,然后将其自动部署到 google App Engine,以便 App Engine "knows" 秘密变量?
您可以在管道中使用 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
的存储库变量。
假设在 bitbucket 存储库中有一个项目在配置文件中存储秘密 API 密钥,例如 config.json:
{
"secret":
}
是否可以从 bitbucket 管道中的变量中引用 "secret" 变量,然后将其自动部署到 google App Engine,以便 App Engine "knows" 秘密变量?
您可以在管道中使用 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
的存储库变量。