dongyi2993 2019-02-14 09:00
浏览 87

在构建期间将AWS Parameter Store环境变量导出到PHP?

I have a simple Laravel installation that I am trying to set up to run through a AWS CodePipeline using ECS.

What have I done?

My Codepipeline is set up with a buildspec.yml file, where I have specified that it should use a value from the Parameter Store, like


My TEST variable does exist in the Parameter Store and I can get it using the cli.

What do I want to do?

I want my environment variable to be accessible to my Laravel installation, so I can use the Parameter Store to save passwords and usernames for e.g. databases and apis.

What actually happens?

When I try to access the environment variable through php, I'm not getting any value. If I var_dump $_ENV, then I cannot see my TEST_STRING in the given array.

I'm quite sure that the environment variable only exists in the build process, but I cannot figure out how to "transfer" the environment variable from my build process to the deployed code.


What am I missing to make the environment variables from the build process available to the deployed code?

  • 写回答

1条回答 默认 最新

  • duanan1946 2019-02-14 12:54

    Go to your cluster and the find your Task Definitions for the relevant task you want to add some environment variables to.

    Click to create a new revision of the task you wish to add variables to.

    Under "Container definitions" you have a list of containers on that task. Select the relevant container and a modal will roll from the right of the screen.

    Scroll down a bit and find Environment > Environment Variables. Here you can add environment variables. You can either set a static value (by using "value") or a Parameter Store value (by using "valueFrom").

    Save your new revision and remember to update your service to use the new definition.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥18 深度学习tensorflow1,ssdv1,coco数据集训练一个模型
  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方