service cc-ui-service无法放置任务,因为没有容器实例满足其所有要求。原因:在群集中未找到容器实例。
答案 0 :(得分:0)
我也遇到了这个错误,从一开始甚至没有集群。因此,也许您可以花我的精力(与Fargate一起完成,但其中一些也可以在ec2上使用)。
Parameters:
Image:
Description: The docker image
Type: String
Default: f00b4r
ImageVersion:
Description: The docker image version
Type: String
Default: "1.0.42"
LogGroupName:
Description: The CloudWatch log group
Type: String
Default: f00b4r-logs
Resources:
AvTestCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: NewCluster
ServiceTaskRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Sub "${AWS::StackName}-TaskRole"
Path: "/"
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- ecs-tasks.amazonaws.com
Action:
- sts:AssumeRole
Policies:
- PolicyName: !Sub "${AWS::StackName}-TaskRolePolicy"
PolicyDocument:
Statement:
- Effect: Allow
Action:
- s3:*
- dynamodb:*
Resource: "*" # TODO: Set to least privilege
ExecutionRole:
Type: AWS::IAM::Role
Properties:
RoleName: ExecutionRoleFargate
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: ecs-tasks.amazonaws.com
Action: 'sts:AssumeRole'
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy'
ServiceSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
VpcId: vpc-02d42422a429042
GroupDescription: Access to the ECS Service
SecurityGroupIngress:
- CidrIp: 42.42.42.42/16
IpProtocol: -1
EcsService:
Type: AWS::ECS::Service
Properties:
Cluster: !Ref 'TestCluster'
DesiredCount: '1'
LaunchType: FARGATE
DeploymentConfiguration:
MaximumPercent: 100
MinimumHealthyPercent: 0
NetworkConfiguration:
AwsvpcConfiguration:
AssignPublicIp: DISABLED
SecurityGroups:
- !Ref ServiceSecurityGroup
Subnets:
- subnet-0345b4296042a84
- subnet-02f3452b9c142de
TaskDefinition: !Ref 'TaskDefinition'
TaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: new-latest
NetworkMode: awsvpc
RequiresCompatibilities:
- FARGATE
Cpu: 256
Memory: 0.5GB
ExecutionRoleArn: !Ref ExecutionRole
TaskRoleArn: !GetAtt ServiceTaskRole.Arn
ContainerDefinitions:
- Name: new-latest
Essential: true
Image:
Fn::Join:
- ""
- - "84272424226"
- ".dkr.ecr.eu-west-1.amazonaws.com/"
- !Ref Image
- ":"
- !Ref ImageVersion
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group:
!Ref LogGroupName
awslogs-region: !Ref AWS::Region
awslogs-stream-prefix: new-latest
Memory: 128
Command: ["sh", "-c", !Join [ "", [ "echo HelloFromFargate" ] ] ]
RestoreUptimeQuotationDDBECSRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service:
- events.amazonaws.com
Action:
- sts:AssumeRole
Path: /
Policies:
- PolicyName: NewPolicy
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: 'ecs:RunTask'
Resource: !Ref TaskDefinition
LogGroup:
Type: "AWS::Logs::LogGroup"
Properties:
RetentionInDays: 30
LogGroupName:
!Ref LogGroupName