在AWS S3上为静态网站配置环境变量 [英] Configuring environment variables for static web site on AWS S3

查看:234
本文介绍了在AWS S3上为静态网站配置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据信息在S3上设置一个简单的静态Angular网站: http://docs.aws.amazon.com/gettingstarted/latest/swh/website-hosting-intro.html

I am trying to setup a simple static Angular website on S3 per the info: http://docs.aws.amazon.com/gettingstarted/latest/swh/website-hosting-intro.html

我想通过需要发送sendgrid api密钥的表单发送电子邮件.显然,我想为此使用环境变量以避免代码中包含键.如何在S3中设置环境变量?

I want to send email via a form that needs to send sendgrid api keys. Obviously, I want to use environment variables for this to avoid having keys in code. How do you setup environment variables in S3?

我研究了aws-cli工具,但它仅显示了一些似乎是AWS特定环境变量的示例.可以在AWS/S3控制台中的某个地方进行设置吗?

I looked into aws-cli tool but it only shows examples of what appear to be AWS specific enviroment variables. Is there somewhere in AWS/S3 console were these can be set?

顺便说一句,我想使用这个Angular服务来演示sendgrid服务: https://github.com/onaclovtech/sendgrid/blob/master/sendgrid.js

BTW- I would like to use this Angular service which demonstrates the sendgrid service: https://github.com/onaclovtech/sendgrid/blob/master/sendgrid.js

推荐答案

您不能在S3中设置环境变量. S3只是静态对象存储,而不是动态内容服务器.评估变量值将是动态内容的定义,而S3仅提供静态内容.

You can't set environment variables in S3. S3 is just a static object store, not a dynamic content server. To evaluate variable values would be the very definition of dynamic content, and S3 only serves static content.

请注意,AngularJS代码在浏览器中运行,而不是在服务器上运行,因此任何想看的人都可以在浏览器中查看要保留在代码之外的那些键.如果要从客户端框架调用SendGrid,则无法隐藏这些值.

Note that AngularJS code runs in the browser, not on a server, so those keys you want to keep out of your code are going to be viewable in the browser by anyone that knows how to look. There's no way for you to hide those values if you want to call SendGrid from a client-side framework.

这篇关于在AWS S3上为静态网站配置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆