我正在使用 Zappa 部署 Flask 应用程序。它有效(site)。显然,我不希望它停留在 aws 域后面并将其放在我的个人域中。
我正在搜索的所有内容都在谈论使用 S3 和 API Gateway 托管 Lambda 站点。有没有办法将我的小应用程序部署到自定义域?
编辑
在@mislav 的回答之后,我能够让我的谷歌域与 AWS 一起工作。但是当我尝试通过运行 zappa certify
来完成时我收到有关现有域的错误:
raise error_class(parsed_response, operation_name) botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the CreateDomainName operation: The domain name you provided already exists.
我的
zappa_settings.json
是{
"dev": {
"app_function": "ping_app.app",
"aws_region": "us-west-1",
"profile_name": "Breuds",
"project_name": "breuds",
"runtime": "python3.6",
"s3_bucket": "zappa-ping-redshift",
"slim_handler": true,
"certificate_arn": "arn:aws:acm:us-east-1:010174774769:certificate/3a92c204-5788-42fc-bc65-74aaae8c1b3f",
"domain": "breuds.com"
}
}
我开始认为我在我的域方面做一些令人费解的事情。我正在使用 Google Domains(因为我的电子邮件有一个自定义域,只是使用它),但这似乎会导致试图让 AWS 与之交谈令人头疼。
最佳答案
zappa’s readme中其实有解释.
Deploying to a Domain With AWS Certificate Manager
Amazon provides their own free alternative to Let's Encrypt called AWS Certificate Manager (ACM). To use this service with Zappa:
Verify your domain in the AWS Certificate Manager console. In the console, select the N. Virginia (us-east-1) region and request a certificate for your domain or subdomain (sub.yourdomain.tld), or request a wildcard domain (*.yourdomain.tld). Copy the entire ARN of that certificate and place it in the Zappa setting certificate_arn. Set your desired domain in the domain setting. Call $ zappa certify to create and associate the API Gateway distribution using that certificate.
还有使用现有证书等的说明。
不要让它愚弄你,这部分的标题听起来像是关于证书的,但是有关于使用你自己的域的详细说明。
编辑:
我包括 my own zappa settings以供引用。
{
"common": {
"app_function": "app.__hug_wsgi__",
"aws_region": "eu-central-1",
"s3_bucket": "excuse-generator",
"profile_name": "mislavcimpersak",
"remote_env": "s3://excuse-generator/secrets.json",
"certificate_arn": "arn:aws:acm:us-east-1:500819636056:certificate/3edb9c1c-12c5-4601-89a9-dc42df840fa6"
},
"prod": {
"extends": "common",
"domain": "function.xkcd-excuse.com"
},
"dev": {
"extends": "common",
"debug": true,
"keep_warm": false,
"domain": "function-dev.xkcd-excuse.com"
}
}
在 namecheap.com 上购买并通过 cloudflare.com 提供服务的域名的分步指南
foo.example.com
& foo-dev.example.com
)zappa_settings.json
在 certificate_arn
下输入您的 ARN zappa_settings.json
在 route53_enabled
下把 false
- 这是必须的 zappa_settings.json
在 domain
下输入每个阶段的域,即。 foo.example.com
和 foo-dev.example.com
zappa certify <stage_name>
证书已更新!”
关于flask - 我可以将 AWS Lambda 站点移动到私有(private)域吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47604237/