简体   繁体   English

如何在 Angular 应用程序中访问 ECS 容器内的 AWS .env 变量?

[英]How to access AWS .env variables inside the ECS container in an angular app?

I am using ECR to store an Angular app that goes in as an image.我正在使用 ECR 存储作为图像进入的 Angular 应用程序。 Now I have keys, URLs, etc that I wish to access inside the container running on ECS, passed through in the ECS container definitions.现在我有了希望在 ECS 上运行的容器内访问的密钥、URL 等,这些密钥、URL 等在 ECS 容器定义中传递。

I have tried dotenv that dynamically picks up env variables and write the file environment.ts everytime you do an npm start but the issue with this is, that when an image is being built it is again hardcoded in the file and not something that is being accessed through a containers environment, where the ECS environment variables are.我尝试过dotenv每次执行npm start动态获取 env 变量并写入文件environment.ts但问题是,当构建图像时,它会再次硬编码在文件中,而不是正在生成的东西通过 ECS 环境变量所在的容器环境访问。

I have no idea how to do that since process.env does not work in an angular environment, and I believe it won't work either since the Angular app is essentially just HTML, CSS, and JS after being built (No node server whatsoever).我不知道该怎么做,因为process.env在 Angular 环境中不起作用,而且我相信它也不起作用,因为 Angular 应用程序在构建后本质上只是 HTML、CSS 和 JS(没有任何节点服务器)。

So, In such a scenario, How do I even make environment variables work?那么,在这种情况下,我什至如何使环境变量起作用?

检查可能会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM