如何为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
專家
已提問 7 個月前檢視次數 2 次
1 個回答
0

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

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

python3 -u {artifacts:decompressedPath}/secret_loader/main.py {configuration:/secretArn}
profile picture
專家
已回答 7 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南