aws启动
by Daniel Simmons
丹尼尔·西蒙斯(Daniel Simmons)
如何在15分钟内免费在AWS上启动网站 (How to launch a site on AWS for free in 15 minutes)
If you‘re completely new to Amazon Web Services (AWS), it can come across as soul-crushingly complicated.
如果您是Amazon Web Services(AWS)的新手,那么它可能会非常复杂。
Not only does it seem like there’s a thousand different services to choose from, each of which has an equally cryptic name (like S3, Lambda, EC2, or Athena), but there is also so much to configure.
它不仅看起来像有一千个不同的服务可供选择,每一个都有一个同样神秘的名称(如S3,λ,EC2,或者Athena),但也有这么 多 配置。
You’ve gotta decide how much memory to allocate to your functions, which geographic region of the world you want your code to be served from, and you have to build a weird JSON object in order to grant permissions? It’s REALLY easy to dip your toes in and decide it’s too confusing to get started.
您必须确定要分配给函数的内存量,要从中服务代码的世界哪个地理区域,并且必须构建一个怪异的JSON对象才能授予权限? 踩入脚趾并确定入门太混乱,这真的很容易。
If this describes your experience so far, then good — this article is for you.
如果这描述了您到目前为止的经验,那就很好了-本文适合您。
I was in the exact same boat for longer than I’d care to admit.
我在同一条船上待了比我愿意承认的时间更长的时间。
But despite all of its daunting complexity, there is something about AWS that just keeps calling out to you.
但是,尽管它具有令人生畏的所有复杂性,但关于AWS的某些东西一直在不断地向您呼吁。
There’s the speed, the reliability, even just the professional clout of being able to say that you have experience with AWS.
速度,可靠性,甚至是能够说出您具有AWS经验的专业影响力。
But, like with anything, if you want to get started, then you need to take the first step. So my goal in this article is to make that an easy one. I want to get you to the point that you can say “I have deployed a project on AWS.”
但是,与任何事物一样,如果要开始使用,则需要迈出第一步。 因此,我在本文中的目标是使其变得简单。 我想让您说出“我已经在AWS上部署了一个项目”。
It will be much easier than you think, and it will give you a point from which to begin exploring AWS’s other services.
这将比您想象的要容易得多,并且它将为您提供一个起点,以开始探索AWS的其他服务。
步骤0:您需要遵循的步骤 (Step 0: What you’ll need to follow along)
The list is short, but I figured I’d put it front and center to make sure it’s clear from the beginning.
清单很短,但我想我会把它放在前面和中间,以确保从头开始就清楚。
- A working credit / debit card (don’t worry, it’s all free like the title says. But you will need to enter credit card info in order to create an AWS account) 可以使用的信用卡/借记卡(不用担心,它完全免费,如标题所述。但是您需要输入信用卡信息才能创建一个AWS账户)
Front-end code that you can upload and host on AWS. This can be as simple as an HTML document with
<p>Hello Wor
ld</p> in the body.您可以上传并托管在AWS上的前端代码。 这可以像正文中带有
<p>Hello Wor
ld </ p>HTML文档一样简单。
步骤1:注册一个AWS账户 (Step 1: Make an AWS Account)
To be honest, I stopped at this point several times simply because it was one of those “free trial but they ask for your credit card info” situations, which I tend to resist on principle.
老实说,我在这一点上停了好几次,仅仅是因为这是“免费试用,但他们要求您提供信用卡信息”的情况之一,我倾向于原则上拒绝这样做。
But the 12 month free tier is pretty amazing. A full year is a long time to be able to experiment on AWS before deciding whether it’s worth continuing to use it. (I am not in any way affiliated with AWS, just for the record).
但是12个月的免费套餐非常惊人。 在决定是否值得继续使用AWS之前,整整一年的时间是很长的时间。 (出于记录目的,我绝不隶属于AWS)。
So follow this link and create your account: AWS Free Tier.
因此,请单击此链接并创建您的帐户: AWS Free Tier 。
I know some people might have some concerns about the limitations on the free plan. For example, there is a monthly cap on GET and PUT requests (20,000 and 2,000 respectively), after which point you start getting charged.
我知道有些人可能会对免费计划的局限性有所担忧。 例如,GET和PUT请求有一个每月上限(分别为20,000和2,000),此后您便开始收费。
But as long as you’re only using this to experiment and learn for now, there’s pretty much no chance of exceeding the limitations.
但是,只要您现在仅使用它来进行实验和学习,就几乎没有机会超过限制。
And even if you do, the pricing for exceeding the caps is typically fractions of a penny per 1,000 requests.
即使您这样做,超出上限的价格也通常是每千个请求一分钱的几分之一。
步骤2:为您的项目/站点创建一个S3存储桶 (Step 2: Create an S3 bucket for your project/site)
To keep things as simple as possible, the only AWS service that we’ll be using for this project will be Simple Storage Service (or S3), one of Amazon’s cloud storage services.
为了使事情尽可能简单,我们将用于该项目的唯一AWS服务将是简单存储服务(S3),这是Amazon的云存储服务之一。
S3 behaves a bit like Google Drive or Dropbox. But it can also be configured to serve files rather than just store them, which is what we’ll be doing.
S3的行为有点像Google云端硬盘或Dropbox。 但是,也可以将其配置为提供文件,而不仅仅是存储文件,这就是我们要做的。
Since we’ll just be serving files that are hosted on S3, this will be a static site, with no backend or connections to a database.
由于我们将只提供S3上托管的文件,因此这将是一个静态站点,没有后端或与数据库的连接。
Now that you’ve got an AWS account, log in to the Management Console (linked here) and click on “Services” in the upper left of the main menu.
现在您已经拥有一个AWS账户,登录到管理控制台( 在此处链接 ),然后单击主菜单左上方的“服务”。
You’ll see that mind-bogglingly large list of service options that I mentioned in the beginning. Don’t worry about all that, just click on “S3” under the “Storage” section.
您会看到我一开始提到的庞大的服务选项列表。 不必担心所有这些,只需单击“存储”部分下的“ S3”。
This will take you to the S3 page, where you can create different “buckets” to store your different projects.
这将带您到S3页面,您可以在其中创建不同的“存储桶”以存储您的不同项目。
Buckets are like folders on your desktop. But the document storage system on S3 does not follow the traditional folder structure (more on that if you’re interested). So instead,“bucket” seems to be the right word to use.
桶就像您桌面上的文件夹。 但是S3上的文档存储系统不遵循传统的文件夹结构( 如果您有兴趣的话,可以查看其更多内容 )。 因此,“ bucket”似乎是使用的正确词。
Click on the big blue button in the upper left called “Create Bucket” to create a bucket that will hold your project files.
单击左上角名为“创建存储桶”的蓝色大按钮,创建一个存储您的项目文件的存储桶。
The main thing that you need to do here is make sure the public permissions are set to “Grant public read access to this bucket.”
您在这里需要做的主要事情是确保将公共权限设置为“授予对此存储桶的公共读取访问权限”。
You’ll get a warning from AWS, but don’t worry. They just want to make sure that no one could do this by accident. But this is exactly what you want to do.
您会收到来自AWS的警告,但请不要担心。 他们只是想确保没有人会偶然地这样做。 但这正是您想要做的。
Once you’re done, you’ll see your bucket in the list on your S3 console.
完成后,您将在S3控制台的列表中看到存储桶。
第3步:添加文件并在存储桶上配置设置 (Step 3: Add files & configure the settings on your bucket)
Click on your newly created bucket in the list. This will bring you to a page where you can add contents to your bucket and configure its settings.
在列表中单击您新创建的存储桶。 这将带您到一个页面,您可以在其中添加内容到存储桶并配置其设置。
First, you’ll want to add your project files (mentioned at the beginning) on the “Overview” tab. Remember, these can be the files for any functioning front-end project.
首先,您需要在“概述”选项卡上添加项目文件(开头提到)。 请记住,这些可以是任何正常运行的前端项目的文件。
You won’t be able to upload any folders (again, since S3 doesn’t actually have a folder structure). Instead, you’ll need to manually create any folders that you have in your project in S3 and upload your files to them.
您将无法上载任何文件夹(同样,由于S3实际上没有文件夹结构)。 相反,您需要在S3中的项目中手动创建您拥有的所有文件夹,然后将文件上传到这些文件夹。
Next, click on the “Properties” tab.
接下来,单击“属性”选项卡。
This is where you’ll tell S3 that you want to use this bucket to host your files.
在这里,您将告诉S3您要使用此存储桶来托管文件。
Just click on the tile that says “Static Website Hosting” and enter the names of your index (required) and error (not required) documents and you’re all done.
只需单击显示“静态网站托管”的图块,然后输入索引(必需)和错误(不需要)文档的名称,就可以完成所有工作。
Next, click on the “Permissions” tab.
接下来,单击“权限”选项卡。
You’ll see just below the main tabs that you start off in a subsection called “Access Control List”. This is already configured correctly, since you’ve already said that anyone should be able to read the files hosted in this bucket.
您会在“访问控制列表”小节中看到的主要选项卡正下方。 这已经正确配置,因为您已经说过任何人都应该能够读取此存储桶中托管的文件。
Now you’ll need to click on the “Bucket Policy” subsection. Here, you’ll be prompted to create a JSON object that contains the details of your bucket’s access permission policy.
现在,您需要单击“桶策略”小节。 在这里,系统会提示您创建一个JSON对象,其中包含存储桶访问权限策略的详细信息。
This part can be confusing. For now, I’ll just give you the JSON that will grant full public access to the files in your bucket. This will make the website publicly accessible.
这部分可能会令人困惑。 现在,我仅向您提供JSON,它将授予对存储桶中文件的完全公共访问权限。 这将使该网站公开可用。
Paste this into the bucket policy editor shown above:
将此粘贴到上面显示的存储桶策略编辑器中:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "PublicReadForGetBucketObjects", "Effect": "Allow", "Principal": "*", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::YOUR-BUCKET-NAME/*" } ]}
Don’t forget to replace “YOUR-BUCKET-NAME” with… your bucket’s name.
不要忘了用…您的存储桶名称替换“您的存储桶名称”。
你完成了! (You’re done!)
That’s it! You have now deployed a very simple static site on AWS S3.
而已! 现在,您已经在AWS S3上部署了一个非常简单的静态站点。
To access your site, go back to the “Overview” tab on S3 and click on your index document (click on a blank area in the list item, not on the link to the document itself). You’ll get a slide-in menu on the right with a link to your site!
要访问您的站点,请返回S3上的“概述”选项卡,然后单击索引文档(单击列表项中的空白区域,而不是指向文档本身的链接)。 您将在右侧获得一个带有菜单链接的幻灯片菜单!
翻译自: https://www.freecodecamp.org/news/how-to-launch-a-site-on-aws-for-free-in-15-minutes-7b3ce5d8d053/
aws启动