amazon-web-services - CloudFormation 模板在创建 ECS 服务时卡在 CREATE_IN_PROGRESS
问题描述
我正在 CloudFormation 中创建 ECS 服务。
logical ID = Service
我没有收到任何错误,它只会位于阶段的 CREATE_IN_PROGRESS 处。
这是我的 CF 模板(ECS 集群和上面的一些其他内容,但由于相关性而被删除)。
TaskDefinition:
Type: 'AWS::ECS::TaskDefinition'
Properties:
Family: flink
Memory: 2048
Cpu: 512
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
ContainerDefinitions:
- Name: flink-jobmanager
Image: ACCOUNT_ID.dkr.ecr.us-west-1.amazonaws.com/teststack-flink:latest
Essential: true
PortMappings:
- ContainerPort: 8081
HostPort: 8081
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: ecs/flink-stream
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: ecs
Command:
- jobmanager
- Name: flink-taskmanager
Image: ACCOUNT_ID.dkr.ecr.us-west-1.amazonaws.com/teststack-flink:latest
Essential: true
Command:
- taskmanager
ExecutionRoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/ecsTaskExecutionRole
Volumes: []
TaskRoleArn: !Sub arn:aws:iam::${AWS::AccountId}:role/ecsTaskExecutionRole
Tags:
-
Key: EnvironmentStage
Value: !Ref EnvironmentStage
Service:
Type: 'AWS::ECS::Service'
Properties:
ServiceName: !Join ['', [!Ref EnvironmentStage, '-', !Ref 'AWS::StackName']]
Cluster: !Join ['', ['arn:aws:ecs:', !Ref 'AWS::Region', ':', !Ref 'AWS::AccountId', ':cluster/', !Ref ECSCluster]]
LaunchType: FARGATE
DeploymentConfiguration:
MaximumPercent: 200
MinimumHealthyPercent: 75
TaskDefinition: !Join ['', ['arn:aws:ecs:', !Ref 'AWS::Region', ':', !Ref 'AWS::AccountId', ':task-definition/', !Ref TaskDefinition]]
# TaskDefinition: !Ref TaskDefinition
DesiredCount: 1
DeploymentController:
Type: ECS
EnableECSManagedTags: true
PropagateTags: TASK_DEFINITION
SchedulingStrategy: REPLICA
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: ENABLED
SecurityGroups:
- !Ref FlinkSecurityGroup
Subnets:
- subnet-466da11c
- subnet-6fe65509
Tags:
-
Key: EnvironmentStage
Value: !Ref EnvironmentStage
当我手动设置容器时,它们都部署到集群中
解决方案
检查后clusters -> CLUSTER_NAME -> tasks -> stopped
我看到以下内容:
Status reason CannotStartContainerError: Error response from daemon:
failed to initialize logging driver: failed to create Cloudwatch log stream:
ResourceNotFoundException: The specified log group does not exist.
问题只是我忘记在log group
我的 CF 模板中添加 to 的创建。所以我添加了这个:
LogGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Sub ${EnvironmentStage}-service-flink
然后将LogConfiguration
in修改TaskDefinition
为:
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref LogGroup
awslogs-region: !Ref 'AWS::Region'
awslogs-stream-prefix: flink
现在 CF 模板就像一个魅力 :)
推荐阅读
- blazor - Blazor 上的hangfire RecurringJob
- python-3.x - python - 如何在python pandas中对以数据框的某个单词结尾的某些列求和?
- java - 具有多个手机客户端的 Spring Boot TCP 服务器
- swift - 视图控制器显示为弹出窗口
- gnuplot - 具有自定义范围的 Gnuplot 偏移量 (v5.4)
- mysql - 我如何将动态表单的值从反应发送到节点 js
- c - C语言:给定一个字符串,删除/删除包含n个元音的单词
- c++ - 如何修复代码块(语言 C)中的 ssrteam 致命错误?
- python - 带有“secondary_y”的 Matplotlib:如何将图例重新定位到左下角?
- shell - 如何在awk中修改来自ifconfig的输入