AWS 代码管道 "An AppSpec file is required, but could not be found in the revision"

AWS CodePipeline "An AppSpec file is required, but could not be found in the revision"

我正在尝试使用 CodeCommit、ECR 和 ECS 设置部署管道。我的管道顺利通过了源代码和构建步骤。如果我将 appspec.yaml 文件上传到 s3 存储桶,我可以通过 CodeDeploy 手动部署。由对我的 CodeCommit 存储库的更改触发的部署总是失败并显示错误:

An AppSpec file is required, but could not be found in the revision

当我查看失败部署的详细信息时,我可以拉出修订位置,其中显示:

我在 troubleshooting code deploy 部分看到某些编辑器可能会导致问题。我在 linux 上使用 vscode,所以我认为这不是问题。此外,如果我将 相同的 appspec 文件 上传到 s3 并从手动部署中引用它,它工作正常。

我也试过上传相同的文件,但命名为 appspec.yml。还是失败了。

此部署使用的角色具有完整的 s3 访问权限,不确定是否可能是任何其他与权限相关的问题。

这是我的代码流水线定义:

{
"pipeline": {
    "roleArn": "arn:aws:iam::690517313378:role/service-role/AWSCodePipelineServiceRole-us-east-1-blottermappertf", 
    "stages": [
        {
            "name": "Source", 
            "actions": [
                {
                    "inputArtifacts": [], 
                    "name": "Source", 
                    "region": "us-east-1", 
                    "actionTypeId": {
                        "category": "Source", 
                        "owner": "AWS", 
                        "version": "1", 
                        "provider": "CodeCommit"
                    }, 
                    "outputArtifacts": [
                        {
                            "name": "SourceArtifact"
                        }
                    ], 
                    "configuration": {
                        "PollForSourceChanges": "false", 
                        "BranchName": "master", 
                        "RepositoryName": "blottermapper"
                    }, 
                    "runOrder": 1
                }
            ]
        }, 
        {
            "name": "Build", 
            "actions": [
                {
                    "inputArtifacts": [
                        {
                            "name": "SourceArtifact"
                        }
                    ], 
                    "name": "Build", 
                    "region": "us-east-1", 
                    "actionTypeId": {
                        "category": "Build", 
                        "owner": "AWS", 
                        "version": "1", 
                        "provider": "CodeBuild"
                    }, 
                    "outputArtifacts": [
                        {
                            "name": "BuildArtifact"
                        }
                    ], 
                    "configuration": {
                        "ProjectName": "blottermapper", 
                        "EnvironmentVariables": "[{\"name\":\"REPOSITORY_URI\",\"value\":\"690517313378.dkr.ecr.us-east-1.amazonaws.com/net.threeninetyfive\",\"type\":\"PLAINTEXT\"}]"
                    }, 
                    "runOrder": 1
                }
            ]
        }, 
        {
            "name": "Deploy", 
            "actions": [
                {
                    "inputArtifacts": [
                        {
                            "name": "BuildArtifact"
                        }
                    ], 
                    "name": "Deploy", 
                    "region": "us-east-1", 
                    "actionTypeId": {
                        "category": "Deploy", 
                        "owner": "AWS", 
                        "version": "1", 
                        "provider": "CodeDeploy"
                    }, 
                    "outputArtifacts": [], 
                    "configuration": {
                        "ApplicationName": "blottermappertf", 
                        "DeploymentGroupName": "blottermappertf"
                    }, 
                    "runOrder": 1
                }
            ]
        }
    ], 
    "artifactStore": {
        "type": "S3", 
        "location": "codepipeline-us-east-1-634554346591"
    }, 
    "name": "blottermappertf", 
    "version": 1
}, 
"metadata": {
    "pipelineArn": "arn:aws:codepipeline:us-east-1:690517313378:blottermappertf", 
    "updated": 1573712712.49, 
    "created": 1573712712.49
}

}

我在这里找到了答案:

我在设置部署时使用了错误的操作提供程序。我选择了ECS,我应该选择ECS Blue/Green.

模棱两可的错误消息让我很难调试和搜索有关堆栈溢出的答案。

"An AppSpec file is required, but could not be found in the revision"

以上错误与您的代码管道配置错误有关。要执行 ECS codedeploy 部署,用于部署的 codepipeline 阶段中的提供商必须是 "ECS (blue/green)" 而不是 "Codedeploy"(codedeploy 用于 EC2 部署。)

即使在后端它使用 codedeploy,提供者的名称是 "ECS (blue/green)"。