【问题标题】:AWS CloudFormation Create-Stack Service Resource Hanging at 'CREATE_IN_PROGRESS'AWS CloudFormation Create-Stack 服务资源挂在“CREATE_IN_PROGRESS”
【发布时间】: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


    【解决方案1】:

    啊,我可以去 ecs 中的服务并查看那里的事件选项卡: service booksapi failed to launch a task with (error ECS was unable to assume the role 'iamRoleHere' that was provided for this task. Please verify that the role being passed has the proper trust relationship and permissions and that your IAM user has permissions to pass this role.).

    【讨论】:

    • 请将此添加为评论或更新您的问题,因为这不是答案。鉴于您已经有一个角色 iamRoleHere 存在,您可以通过传递角色 ARN 来检查,而不仅仅是传递应该类似于 arn:aws:iam::***account_id***:role/iamRoleHere 的角色名称。
    猜你喜欢
    • 2021-10-24
    • 2020-02-13
    • 2015-12-20
    • 1970-01-01
    • 2022-11-16
    • 2018-10-25
    • 2020-01-27
    • 2021-05-24
    • 2019-11-30
    相关资源
    最近更新 更多