基于AWS Code Build documentation,我们可以通过EnvironmentVariables
类型传递PARAMETER_STORE
。
我已确保参数存储名称正确输入 ,并且参数已存在 。
我尝试通过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
类型,并且效果很好。
答案 0 :(得分:1)
这是设计使然。
参数存储中的值被视为敏感。
因此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