我创建了一个使用docker image for node8的代码构建项目。这个codebuild项目的目的是进行单元测试。它从codecommit获取一个输入工件。在buildspec.yml中,它运行一个测试命令。
这是我的(简单)buildspec文件:

version: 0.2

phases:
  install:
    commands:
     - echo "install phase started"
     - npm install
     - echo "install phase ended"
  pre_build:
    commands:
     - echo "pre_build aka test phase started"
     - echo "mocha unit test"
     - npm test
     - echo "mocha unit test ended"
  build:
    commands:
     - echo "build phase started"
     - echo "build complete"

生成在下载源阶段失败,原因如下:
阶段-下载源
开始时间2分钟前
结束时间2分钟前
消息访问被拒绝
生成日志中唯一的日志如下
【集装箱】2018/01/12 11:30:22等待平探员
[容器]2018/01/12 11:30:22等待下载源
提前谢谢。
代码生成策略的屏幕截图。
node.js - 下载源时,AWS Codebuild失败。消息:访问被拒绝-LMLPHP

最佳答案

我找到了解决办法。我的权限有问题。我加了这个让它工作。

{
"Version": "2012-10-17",
"Statement": [
    {
        "Effect": "Allow",
        "Resource": [
            "arn:aws:logs:eu-west-1:723698621383:log-group:/aws/codebuild/project",
            "arn:aws:logs:eu-west-1:723698621383:log-group:/aws/codebuild/project:*"
        ],
        "Action": [
            "logs:CreateLogGroup",
            "logs:CreateLogStream",
            "logs:PutLogEvents"
        ]
    },
    {
        "Effect": "Allow",
        "Resource": [
            "arn:aws:s3:::codepipeline-eu-west-1-*"
        ],
        "Action": [
            "s3:PutObject",
            "s3:GetObject",
            "s3:GetObjectVersion"
        ]
    },
    {
        "Effect": "Allow",
        "Action": [
            "ssm:GetParameters"
        ],
        "Resource": "arn:aws:ssm:eu-west-1:723698621383:parameter/CodeBuild/*"
    }
  ]
}

08-07 13:46