【发布时间】:2020-07-11 02:52:02
【问题描述】:
除了挂在“CREATE_IN_PROGRESS”的服务资源之外,我的以下 cloudformation 脚本在我的 create-stack 命令中运行良好。希望你们都能看到我遗漏的一些明显的问题。
除了仅显示挂起状态行的“事件”页面之外,我没有看到任何方法可以更深入地了解它在进程中所处的位置,但如果可以的话,我很乐意提供更多信息。
AWSTemplateFormatVersion: '2010-09-09'
Description: container on ecs cluster
Resources:
# Defines container. This is a simple metadata description of what
# container to run, and what resource requirements it has.
Task:
Type: AWS::ECS::TaskDefinition
Properties:
Family: apis
Cpu: 256
Memory: 512
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
ExecutionRoleArn: 'iamRoleHere'
ContainerDefinitions:
- Name: booksapi
# this is the image name from our repo that we made early on: aws ecr describe-repositories
Image: 'imageHere'
Cpu: 256
Memory: 512
PortMappings:
- ContainerPort: 50577
Protocol: tcp
# The service. The service is a resource which allows you to run multiple
# copies of a type of task, and gather up their logs and metrics, as well
# as monitor the number of running tasks and replace any that have crashed.
# defines how the task or container will be scheduled and deployed in the cluster and how the container instances will be registered with load balancer
Service:
Type: AWS::ECS::Service
DependsOn: ListenerRule
Properties:
#if using param for servicename: !Ref 'ServiceName'
ServiceName: booksapi
TaskDefinition: !Ref 'Task'
Cluster: !ImportValue 'ECSCluster'
LaunchType: FARGATE
DesiredCount: 2
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 70
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
Subnets:
- 'subnet-abctyui'
- 'subnet-poyfdha'
SecurityGroups:
- !ImportValue ContainerSecurityGroup
LoadBalancers:
- ContainerName: booksapi
ContainerPort: 50577
TargetGroupArn: !Ref TargetGroup
# A target group. This is used for keeping track of all the tasks, and
# what IP addresses / port numbers they have. You can query it yourself,
# to use the addresses yourself, but most often this target group is just
# connected to an application load balancer, or network load balancer, so
# it can automatically distribute traffic across all the targets.
# add 443 after POC. remove health check for now as it is buggy at the moment in our template
TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: books-tg
VpcId: 'vpc-ljhdfrr'
Port: 80
Protocol: HTTP
Matcher:
HttpCode: 200-299
HealthCheckIntervalSeconds: 10
HealthCheckPath: /stat
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 10
TargetType: ip
ListenerRule:
Type: AWS::ElasticLoadBalancingV2::ListenerRule
Properties:
ListenerArn: !ImportValue Listener
Priority: 2
Conditions:
- Field: path-pattern
Values:
- /v1/books*
Actions:
- TargetGroupArn: !Ref TargetGroup
Type: forward
Outputs:
ApiEndpoint:
Description: Tests API Endpoint
Value: !Join ['', ['http://', !ImportValue DomainName, '/v1/books']]
Export:
Name: 'BooksApiEndpoint'
【问题讨论】:
标签: amazon-web-services yaml amazon-cloudformation amazon-ecs