[英]AWS reference solution for a serverless SaaS system - Error: Template file not found - template.yml
I'm trying to deploy an AWS reference solution using AWS Cloud9, that demonstrates a sample SaaS system.我正在尝试使用 AWS Cloud9 部署一个 AWS 参考解决方案,它演示了一个示例 SaaS 系统。 The repo for the solution is here:解决方案的回购协议在这里:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/blob/main/DOCUMENTATION.md https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/blob/main/DOCUMENTATION.md
There's a deployment file that can be run in order to bootstrap the example system in AWS - it's /aws-saas-factory-ref-solution-serverless-saas/deployment.sh
within the repo.有一个部署文件可以运行以在 AWS 中引导示例系统 - 它是 repo 中的/aws-saas-factory-ref-solution-serverless-saas/deployment.sh
。
Part of the deployment script builds bootstrap resources using the file /aws-saas-factory-ref-solution-serverless-saas/server/bootstrap-template.yaml
, which is a CloudFormation template.部分部署脚本使用文件/aws-saas-factory-ref-solution-serverless-saas/server/bootstrap-template.yaml
构建引导程序资源,这是一个 CloudFormation 模板。 The script then deploys bootstrap resources based on the configuration file /aws-saas-factory-ref-solution-serverless-saas/server/samconfig-bootstrap.toml
该脚本然后根据配置文件/aws-saas-factory-ref-solution-serverless-saas/server/samconfig-bootstrap.toml
部署引导程序资源
The relevant parts of ./deployment.sh
that perform the build and bootstrap are as follows.执行构建和引导程序的./deployment.sh
的相关部分如下。 The build and deployment utilise the AWS 'Serverless Application Model' (sam):构建和部署利用 AWS“无服务器应用程序模型”(sam):
sam build -t bootstrap-template.yaml --use-container --region=$REGION
sam deploy --config-file samconfig-bootstrap.toml --region=$REGION --parameter-overrides AdminEmailParameter=$1
When I run the ./deployment.sh
on a Cloud 9 instance on EC2 (in Singapore region), I get the following error during the common resource bootstrapping stage:当我在 EC2(新加坡区域)上的 Cloud 9 实例上运行./deployment.sh
时,在公共资源引导阶段出现以下错误:
[11034] Failed to execute script main
sam deploy --config-file samconfig-bootstrap.toml --region=ap-southeast-1 --parameter-overrides AdminEmailParameter=chris.halcrow@elenium.com
Error: Template file not found at /home/ec2-user/environment/aws-saas-factory-ref-solution-serverless-saas/server/template.yml
I'm not seeing anything when I search the code for template.yml
, so I'm not sure what's attempting to reference this.当我搜索template.yml
的代码时,我没有看到任何东西,所以我不确定是什么试图引用它。 The file isn't present in the solution.该文件不存在于解决方案中。
The guide here describes how to quickly set up an AWS Cloud9 environment running on an EC2 instance, into which the solution can be cloned from its Github repo in order to run the ./deployment.sh
script - https://catalog.us-east-1.prod.workshops.aws/workshops/b0c6ad36-0a4b-45d8-856b-8a64f0ac76bb/en-US/pre-requisites/12-own-aws-account此处的指南描述了如何快速设置在 EC2 实例上运行的 AWS Cloud9 环境,可以从其 Github 存储库中将解决方案克隆到其中以运行./deployment.sh
脚本 - https://catalog.us- east-1.prod.workshops.aws/workshops/b0c6ad36-0a4b-45d8-856b-8a64f0ac76bb/en-US/pre-requisites/12-own-aws-account
After looking at the build-spec file (buildspec.yaml files are used to provide meta-data for CI/CD in AWS CodeBuild), it seems that the AWS team is testing the deployment using CI/CD Pipelines and forgot to update the shell script.查看构建规范文件(buildspec.yaml 文件用于在 AWS CodeBuild 中为 CI/CD 提供元数据)后,似乎 AWS 团队正在使用 CI/CD 管道测试部署并忘记更新 shell脚本。
You on the other hand don't need to worry about the the build-spec file.另一方面,您无需担心构建规范文件。
Solution解决方案
Go and just change template.yml
to tenant-template.yaml
Go 只需将template.yml
更改为tenant-template.yaml
I found out that template.yml
is an artifact that's normally produced during the build process - see SAM deploy command reference我发现template.yml
是一个通常在构建过程中生成的工件 - 请参阅SAM 部署命令参考
sam deploy
By default when you use this command, the AWS SAM CLI assumes that your current working directory is your project's root directory.默认情况下,当您使用此命令时,AWS SAM CLI 假定您当前的工作目录是项目的根目录。 The AWS SAM CLI first tries to locate a template file built using the sam build command, located in the.aws-sam subfolder, and named template.yaml. AWS SAM CLI 首先尝试找到使用 sam build 命令构建的模板文件,该文件位于 .aws-sam 子文件夹中,名为 template.yaml。
It seems that the template.yml
wasn't being created due to insufficient memory size of the EC2 instance that Cloud9 was running in.由于运行 Cloud9 的 EC2 实例的 memory 大小不足,似乎没有创建template.yml
。
The solution for this was provided by @ujwalbukka in the following git issue, within the repo for the reference solution:此解决方案由@ujwalbukka在以下 git 问题中提供,在参考解决方案的存储库中:
https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/issues/19 https://github.com/aws-samples/aws-saas-factory-ref-solution-serverless-saas/issues/19
To get the SaaS reference solution to run in Cloud9, I cloned an additional repo inside Cloud9 (the repo for the AWS workshop for the SaaS reference solution).为了让 SaaS 参考解决方案在 Cloud9 中运行,我在 Cloud9 中克隆了一个额外的存储库(SaaS 参考解决方案的 AWS研讨会的存储库)。 I cloned this using git clone https://github.com/aws-samples/aws-serverless-saas-workshop.git
我使用git clone https://github.com/aws-samples/aws-serverless-saas-workshop.git
After cloning that repo, I ran through the steps here to run scripts that exist in the workshop repo, that increase the Cloud9 EC2 instance size and install the prerequisites for running the reference solution.克隆该存储库后,我按照此处的步骤运行车间存储库中存在的脚本,增加 Cloud9 EC2 实例大小并安装运行参考解决方案的先决条件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.