如何为ggv2组件设置环境变量?

0

【以下的问题经过翻译处理】 我已经尝试运行下面这个配置文件,但是组件无法获取变量:SECRET_ARN = os.getenv('SECRET_ARN')

RecipeFormatVersion: '2020-01-25'
ComponentName: "{COMPONENT_NAME}"
ComponentVersion: "{COMPONENT_VERSION}"
ComponentDescription: ''
ComponentPublisher: "{COMPONENT_AUTHOR}"

ComponentConfiguration:
  DefaultConfiguration:
    secretArn: 'no_secret'

Manifests:
- Platform:
    os: linux
  Artifacts:
    - URI: s3://BUCKET_NAME/COMPONENT_NAME/COMPONENT_VERSION/secret_loader.zip
      Unarchive: ZIP
  Lifecycle:
    Setenv: SECRET_ARN={configuration:/secretArn}
    Install: python3 -m pip install --user -r {artifacts:decompressedPath}/secret_loader/requirements.txt
    Run: |
      export SECRET_ARN={configuration:/secretArn}
      python3 -u {artifacts:decompressedPath}/secret_loader/main.py

profile picture
专家
已提问 6 个月前1 查看次数
1 回答
0

【以下的回答经过翻译处理】 我认为应该使用 SECRET_ARN: "{configuration:/secretArn}"Setenv 语法,而不是 SECRET_ARN={configuration:/secretArn}

或者,您可以将密码作为参数传递:

python3 -u {artifacts:decompressedPath}/secret_loader/main.py {configuration:/secretArn}
profile picture
专家
已回答 6 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则