amazon-web-services - AWS Cloudformation 创建堆栈模板错误
问题描述
所以我试图在 CF 中为 API 提供一些资源。我有以下 yml 文件,但我不断收到模板错误并且看不到问题。
AWSTemplateFormatVersion: "2010-09-09"
Description: 'container cluster on ECS, loadbalancer, security groups and cloudwatch'
Resources:
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: 'hello-cluster'
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: ecs-services
Subnets:
#these imports will pull from export name of the vpc stack that we made
- 'subnet-abcdefg'
- 'subnet-abcdefo'
- 'subnet-abcdefp'
SecurityGroups:
#references the LoadBalancerSecurityGroup below
- !Ref LoadBalancerSecurityGroup
#port 80 for POC, then add 443
LoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
#references LoadBalancer above
LoadBalancerArn: !Ref LoadBalancer
Protocol: HTTP
Port: 80
DefaultActions:
- Type: forward
#references target group below
TargetGroupArn: !Ref DefaultTargetGroup
#this is very open, we won't want this
LoadBalancerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Security group for loadbalancer to services on ECS
VpcId: 'vpc-abcdefg'
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
IpProtocol: -1
DefaultTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: default
#imports vpc export name from previous stack
VpcId: 'vpc-abcdefg'
Protocol: 'HTTP'
Port: '80'
#extranious for now
CloudWatchLogsGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: 'apis'
RetentionInDays: 1
## security group for containers simliar to load balancer getting connections from the internet,
## this will allow connections from the load balancer
ContainerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: 'vpc-abcdefg'
GroupDescription: for ecs containers
SecurityGroupIngress:
- SourceSecurityGroupId: !Ref 'LoadBalancerSecurityGroup'
IpProtocol: -1
Outputs:
Cluster:
Value: !Ref ECSCluster
Export:
Name: 'ECSCluster'
Listener:
Description: listener port 80
Value: !Ref LoadBalancerListener
Export:
Name: 'Listener'
ContainerSecurityGroup:
Description: container security group
Value: !Ref ContainerSecurityGroup
Export:
Name: 'ContainerSecurityGroup'
LoadBalancerDNS:
Description: Domain name for the loadbalancer
Value: !GetAtt LoadBalancer.DNSName
Export:
Name: 'DomainName'
当我运行它来创建我的堆栈时,它给了我一个错误。
aws cloudformation create-stack --stack-name app-cluster --template-body file://infra/app-cluster.yml
错误是:An error occurred (ValidationError) when calling the CreateStack operation: Invalid template property or properties [???AWSTemplateFormatVersion]
当我删除前两行并将第一行设为“资源”时,我收到此错误An error occurred (ValidationError) when calling the CreateStack operation: Template format error: At least one Resources member must be defined.
感觉好像我必须错过一些简单的东西,但我只是没有看到它。谢谢
解决方案
推荐阅读
- c# - 使用 KD 树的两个 3D 平面列表之间的最近配合面
- laravel - laravel 7 个人资料更新与电子邮件唯一:用户
- vue.js - 如何从 Vue 3 中的生产构建中删除控制台日志
- sql - SQL Server - 逻辑问题 - 从 ID 中获取排名
- r - R闪亮:滑块输入与小时,反应和绘图之间的链接
- amazon-web-services - 在无服务器框架上请求模板作为单独的文件?
- puppeteer - 为什么 puppeteer 截图页面两次然后页面重新加载
- spring-cloud - 使用 consul 的 Spring 云配置服务器“Discovery Fisrt”
- python - 更快/更懒惰的方式在 python 中将 m*n 均匀随机分成 n 组(每个组有 m 个元素)
- html - 如何设置悬停效果(注意:只有方形边框在悬停时应该像钻石形状一样旋转,而不是图像)