通过代码管道输出“***”从参数存储中获取值
Get value from parameter store via code pipeline output '***'
基于AWS Code Build documentation,我们可以用PARAMETER_STORE
类型传递EnvironmentVariables
。
我确保参数存储名称输入正确并且参数存在。
我尝试通过 aws cli 登录,但它似乎不相关,但仍然得到错误的结果。
这是我的 cloudformation yaml 片段:
- Name: Build
Actions:
- Name: HelloWord
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: "1"
Configuration:
ProjectName: HelloWoldBuild
EnvironmentVariables:
Fn::Sub:
- '[{"name": "NGINX_BASE_IMAGE_TAG","value": "${NGINX_BASE_IMAGE_TAG}","type": "PARAMETER_STORE"}]
- NGINX_BASE_IMAGE_TAG: "/nginx/base"
这是我的 buildspec.yaml
片段:
version: 0.2
phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
- echo "${NGINX_BASE_IMAGE_TAG}"
当我看到 CodeBuild 日志时,输出为“***”。正确的应该是我的参数存储中的值。
怎么会这样?我还是不明白。我已经使用 PLAINTEXT
类型进行了测试并且运行良好。
这是设计使然。
来自参数存储的值被视为敏感值。
因此 CodeBuild 屏蔽了它们,因此它们不会出现在其日志的纯文本中。
要解决这个问题,您可以将其分配给不同的变量,然后打印出来。以下是我第一次尝试处理这个问题:
pre_build:
commands:
- NEW_VAR=${NGINX_BASE_IMAGE_TAG}
- echo "${NEW_VAR}"
另类。将其保存到文件并打印出一个文件:
pre_build:
commands:
- echo ${NGINX_BASE_IMAGE_TAG} > /tmp/test.value
- cat /tmp/test.value
基于AWS Code Build documentation,我们可以用PARAMETER_STORE
类型传递EnvironmentVariables
。
我确保参数存储名称输入正确并且参数存在。
我尝试通过 aws cli 登录,但它似乎不相关,但仍然得到错误的结果。
这是我的 cloudformation yaml 片段:
- Name: Build
Actions:
- Name: HelloWord
ActionTypeId:
Category: Build
Owner: AWS
Provider: CodeBuild
Version: "1"
Configuration:
ProjectName: HelloWoldBuild
EnvironmentVariables:
Fn::Sub:
- '[{"name": "NGINX_BASE_IMAGE_TAG","value": "${NGINX_BASE_IMAGE_TAG}","type": "PARAMETER_STORE"}]
- NGINX_BASE_IMAGE_TAG: "/nginx/base"
这是我的 buildspec.yaml
片段:
version: 0.2
phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
- echo "${NGINX_BASE_IMAGE_TAG}"
当我看到 CodeBuild 日志时,输出为“***”。正确的应该是我的参数存储中的值。
怎么会这样?我还是不明白。我已经使用 PLAINTEXT
类型进行了测试并且运行良好。
这是设计使然。
来自参数存储的值被视为敏感值。
因此 CodeBuild 屏蔽了它们,因此它们不会出现在其日志的纯文本中。
要解决这个问题,您可以将其分配给不同的变量,然后打印出来。以下是我第一次尝试处理这个问题:
pre_build:
commands:
- NEW_VAR=${NGINX_BASE_IMAGE_TAG}
- echo "${NEW_VAR}"
另类。将其保存到文件并打印出一个文件:
pre_build:
commands:
- echo ${NGINX_BASE_IMAGE_TAG} > /tmp/test.value
- cat /tmp/test.value