AWS CodePipeline - Insufficient permissions Unable to access the artifact error

时间:2019-01-09 22:29:20

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

Trying to create and run an AWS CodePipeline that pulls from Github, builds and deploys to an EC2 instance. The pipeline is as follows:

Source (Github) -> Build (AWS CodeBuild) -> Deploy (AWS CodeDeploy)

The source and build steps both succeed. However, deploy fails consistently giving the following error:


Insufficient permissions Unable to access the artifact with Amazon S3 object key '[redacted]-2nd-test-pip/BuildArtif/IbiHzen' located in the Amazon S3 artifact bucket 'codepipeline-us-east-1-[redacted]'. The provided role does not have sufficient permissions.


Below is the IAM policy for the CodeBuild service role policy:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Resource": [
                "arn:aws:logs:us-east-1:362490217134:log-group:/aws/codebuild/[Redacted]-Build-Project",
                "arn:aws:logs:us-east-1:362490217134:log-group:/aws/codebuild/[Redacted]-Build-Project:*"
            ],
            "Action": [
                "logs:CreateLogGroup",
                "logs:CreateLogStream",
                "logs:PutLogEvents"
            ]
        },
        {
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::codepipeline-us-east-1-*"
            ],
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:GetObjectVersion"
            ]
        },
        {
            "Effect": "Allow",
            "Resource": [
                "arn:aws:s3:::codepipeline-us-east-1-[Redacted]/*"
            ],
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:GetObjectVersion"
            ]
        }
    ]
}

The CodePipeline service role created by the pipeline wizard has assigned S3 full access:

            "Action": [
                "elasticbeanstalk:*",
                "ec2:*",
                "elasticloadbalancing:*",
                "autoscaling:*",
                "cloudwatch:*",
                "s3:*",
                "sns:*",
                "cloudformation:*",
                "rds:*",
                "sqs:*",
                "ecs:*"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },

I have confirmed numerous times that the artifact referenced in the pipeline deploy step matches the artifact created by the build step.

If I go and look at path referenced, there is not a directory or zip file (not sure which SHOULD be there, but neither is) with that name. Additionally, a zip file is generated during the build, but it is never named what the deploy step expects.

I've also gone into the build project and attempted builds using other artifact configurations, but they seem to be ignored when running the build through CodePipeline.

Disclaimer: I've seen similar questions posted here and elsewhere on the interwebs, but each of them deal with ECS or another situation that differs from mine. Thank you for your help

1 个答案:

答案 0 :(得分:0)

该问题与角色/政策无关。如前所述,预期的zip文件在S3存储桶中不存在。这是由于buildspec中指定的工件文件路径无效。更正后,将创建zip文件,并且部署不会再因该错误而失败。令我感到奇怪的是,CodePipeline将允许生成的报告成功完成,而无需验证是否确实创建了作为工件并传递到部署步骤的文件。