@0x4447/potato 中文文档教程

发布于 6年前 浏览 44 项目主页 更新于 3年前

Potato

我们构建 Potato 是为了减少时间、压力和戏剧性。 将静态页面部署到 S3 并配置 CloudFront、Certificate Manager 和 Route53 的过程繁琐且容易出错。 它还涉及太多要记住的步骤——因此,马铃薯被种植了。

您可能想知道为什么我们不创建 CloudFormation 模板。 原因很简单:CF 不完全支持 Route53,因此创建证书并使用正确的信息更新域需要特殊的 Lambda。 你可以看到我们很快就会陷入复杂的螺旋。

有了Potato,我们可以用代码来克服CF的所有限制,一次性配置好一切。 Potato 还简化了更新静态站点的过程。

How to install

] sudo npm install -g @0x4447/potato

How to use

] potato -s PATH_TO_FOLDER

Where to get help

] potato -h

What to expect

CLI 提供以下选项:

Update

此选项允许您更新 S3 上站点的内容并自动使 CloudFront 分发缓存失效。 只需提供包含新内容的文件夹的路径,CLI 会自动为您完成剩下的工作。 您所要做的就是按照屏幕上的步骤操作。

Create

这个过程比较复杂,但它会节省你的理智——而且会节省很多时间。 选择此选项时,系统会要求您提供要用于网站的域名。 一旦提供了该信息,其他一切都是自动的。 到那时,您需要做的就是坐下来放松一下。

以下是后台发生的所有事情的列表:

  • listallcertificates
  • lookfordomain_certificate
  • createacertificate
  • getcertificatemetadata
  • listhostedzones
  • lookfordomain
  • updateroute53withcertvalidation
  • checkcertificatevalidity
  • checkifbucket_exists
  • createabucket
  • convertbucketto_site
  • changebucketpolicy
  • upload
  • createadistribution
  • getalldomain_records
  • lookfordomain_entry
  • deletedomainentry
  • createaroute53record
  • printdomainconfiguration

警告:如果证书验证时间过长怎么办? 60 秒后,该应用程序退出并打印出一份详细说明,说明您接下来应该做什么。 花点时间彻底检查打印输出,你会很好的。

Credentials

要使用此 CLI,请创建一个编程用户或创建一个具有以下权限的角色:

  • AmazonS3FullAccess
  • CloudFrontFullAccess
  • AmazonRoute53FullAccess
  • AWSCertificateManagerFullAccess

How to pass the credentials

每次运行 Potato 时,它都会执行以下操作:

  1. Check whether it's running on an EC2 server and whether there's an attached role
  2. If this fails, it will check whether it's running inside a CodeBuld container and then check for a Role
  3. Lastly, if all fails, the app prompts for credentials

Is deployment instant?

不,不是。 以下方面不会立即发生:

  • SSL Certificate confirmation
  • CloudFront distribution

SSL Certificate confirmation

此过程的时间范围从 10 秒到 24 小时不等。 这是完全不可预测的,也没有办法加快这个过程。 因此,如果证书未在 60 秒内得到确认,应用程序将退出。 发生这种情况时,请转到 AWS 控制台以监控证书。

CloudFront distribution

这最多需要 15 或 20 分钟,但是当您到达这一点时,您可以确定配置是正确的。 此时,您只需要等待该过程完成即可。 只有这样,域才能提供网站。

Companion software

Potato CLI 工具也适用于以下软件:

  • Avocado: a mini-framework that enables you to create basic HTML websites without the complexity of modern frameworks
  • Strawberry: allows you to create redirects supporting HTTP and HTTPS for your site.

The End

如果您喜欢这个项目,请考虑给它一个 ????。 并查看我们的 0x4447 GitHub 帐户,其中包含您可能会觉得有用或有趣的其他资源。

该项目由 0x4447 LLC 提供,这是一家专门在 AWS 上构建自定义解决方案的软件公司。 点击此链接了解更多信息:https://0x4447.com。 或者,发送电子邮件至 hello@0x4447.email

???? Potato

We built Potato to cut down on time, stress, and drama. The process of deploying a static page to S3 and configuring CloudFront, Certificate Manager, and Route53 is tedious and prone to error. It also involves too many steps to remember – and so, Potato was grown.

You might wonder why we didn't create a CloudFormation template. The reason is simple: CF doesn't fully support Route53, so creating a certificate and updating the domain with the correct information would require a special Lambda. You can see that we could quickly end up in a complex spiral.

With Potato, we can use code to overcome all the limitations of CF and configure everything in one go. Potato also streamlines the process of updating a static site.

How to install

] sudo npm install -g @0x4447/potato

How to use

] potato -s PATH_TO_FOLDER

Where to get help

] potato -h

What to expect

The CLI offers the following options:

Update

This option allows you to update the content of a site on S3 and automatically invalidate the CloudFront Distribution Cache. Just provide the path to the folder containing the new content, and the CLI automatically does the rest for you. All you have to do is follow the steps on the screen.

Create

This process is more involved, but it will save your sanity - and quite a bit of time. When you select this option, you'll be asked for the domain name you'd like to use for your website. Once that information is provided, everything else is automatic. At that point, all you need to do is sit down and relax.

The following is a list of everything that happens in the background:

  • listallcertificates
  • lookfordomain_certificate
  • createacertificate
  • getcertificatemetadata
  • listhostedzones
  • lookfordomain
  • updateroute53withcertvalidation
  • checkcertificatevalidity
  • checkifbucket_exists
  • createabucket
  • convertbucketto_site
  • changebucketpolicy
  • upload
  • createadistribution
  • getalldomain_records
  • lookfordomain_entry
  • deletedomainentry
  • createaroute53record
  • printdomainconfiguration

WARNING: What if the certificate takes too long to validate? After 60 seconds, the app quits and prints out a detailed explanation of what your next steps should be. Take the time to thoroughly go over the printout, and you'll be good.

Credentials

To use this CLI, create a programmatic user or create a role with the following permissions:

  • AmazonS3FullAccess
  • CloudFrontFullAccess
  • AmazonRoute53FullAccess
  • AWSCertificateManagerFullAccess

How to pass the credentials

Each time you run Potato, it does the following:

  1. Check whether it's running on an EC2 server and whether there's an attached role
  2. If this fails, it will check whether it's running inside a CodeBuld container and then check for a Role
  3. Lastly, if all fails, the app prompts for credentials

Is deployment instant?

No, it's not. The following aspects don't happen right away:

  • SSL Certificate confirmation
  • CloudFront distribution

SSL Certificate confirmation

The time frame for this process ranges from 10 seconds to 24 hours. It's completely unpredictable, and there's no way to speed up the process. Because of this, the app quits if the certificate isn't confirmed within 60 seconds. When that happens, go to the AWS Console to monitor the certificate.

CloudFront distribution

This takes up to 15 or 20 minutes, but when you reach this point, you can be certain that the configuration is correct. At this point, you just need to wait until the process is complete. Only then does the domain deliver the website.

Companion software

The Potato CLI tool also works well with the following software:

  • Avocado: a mini-framework that enables you to create basic HTML websites without the complexity of modern frameworks
  • Strawberry: allows you to create redirects supporting HTTP and HTTPS for your site.

The End

If you enjoyed this project, please consider giving it a ????. And check out our 0x4447 GitHub account, which contains additional resources you might find useful or interesting.

This project is brought to you by 0x4447 LLC, a software company specializing in building custom solutions on top of AWS. Follow this link to learn more: https://0x4447.com. Alternatively, send an email to hello@0x4447.email.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文