带有CodeDeploy to ECS的AWS CodePipeline无法找到appspec.yml

时间:2019-01-08 05:23:14

标签: amazon-web-services amazon-ecs aws-code-deploy aws-codepipeline

我已经使用CodeBuild和CodeDeploy创建了CodePipeline,该代码应部署到活动的ECS集群中。

容器的构建没有任何问题。

buildspec.yml和appspec.yml都位于存储库根目录中,如下所示:

buildspec.yml:

version: 0.2

phases:
  pre_build:
    commands:
      - echo Logging in to Amazon ECR...
      - aws --version
      - $(aws ecr get-login --region $AWS_DEFAULT_REGION --no-include-email)
      - REPOSITORY_URI=555.dkr.ecr.us-east-1.amazonaws.com/name
      - COMMIT_HASH=$(echo $CODEBUILD_RESOLVED_SOURCE_VERSION | cut -c 1-7)
      - IMAGE_TAG=${COMMIT_HASH:=latest}
  build:
    commands:
      - echo Build started on `date`
      - echo Building the Docker image...
      - docker build -t $REPOSITORY_URI:latest .
      - docker tag $REPOSITORY_URI:latest $REPOSITORY_URI:$IMAGE_TAG
  post_build:
    commands:
      - echo Build completed on `date`
      - echo Pushing the Docker images...
      - docker push $REPOSITORY_URI:latest
      - docker push $REPOSITORY_URI:$IMAGE_TAG
      - echo Writing image definitions file...
      - printf '[{"name":"name","imageUri":"%s"}]' $REPOSITORY_URI:$IMAGE_TAG > imagedefinitions.json
artifacts:
    files:
      - appspec.yml
      - imagedefinitions.json

appspec.yml:

version: 1.0
Resources:
  - TargetService:
      Type: AWS::ECS::Service
      Properties:
        TaskDefinition: "arn:aws:ecs:us-east-1:555:task-definition/name:1"
        LoadBalancerInfo:
          ContainerName: "name"
          ContainerPort: "80"
        PlatformVersion: "LATEST"

CodeDeploy失败,并显示以下错误消息:

  

一个AppSpec文件是必需的,但在修订版中找不到

在查看S3中引用的修订工件后,我可以验证档案根目录中是否存在正确的appspec.yml文件,并且如上所述。

此配置可能有什么问题?

1 个答案:

答案 0 :(得分:0)

将文件名和buildspec.yml中的appspec.yml更改为appspec.yaml。