Поэтому я пытаюсь добавить несколько ресурсов в 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.
Чувствую себя как я должно быть, что-то упущено, но я просто не вижу этого. Спасибо