Java – Create a CodeBuild project using an AWS select Docker image with PrivilegedMode=TRUE

Create a CodeBuild project using an AWS select Docker image with PrivilegedMode=TRUE… here is a solution to the problem.

Create a CodeBuild project using an AWS select Docker image with PrivilegedMode=TRUE

I used the following command to confirm that aws/codebuild/java:openjdk-8 is one of the featured CodeBuild images.

$ aws codebuild list-curated-environment-images | grep -A 1 openjdk-8
"name": "aws/codebuild/java:openjdk-8", 
"description": "AWS CodeBuild - Java 8"

Even though aws/codebuild/java:openjdk-8 is a featured image, when I try to create a build project with that image and the PrivilegedMode=true parameter, I get a 4XX error that doesn’t make sense: “PrivilegedMode works.”
Set only for projects with custom or AWS CodeBuild Docker featured images. ”

9    [main] INFO  org.janusgraph.codepipelines.AwsCodePipelinesCi  -
{
    Name: j1pass-bdb-project,
    Source: {Type: CODEPIPELINE,},
    Artifacts: {Type: CODEPIPELINE, Name: null-artifacts,Packaging: NONE},
    Environment: {Type: LINUX_CONTAINER,
    Image: aws/codebuild/java:openjdk-8,
    ComputeType: BUILD_GENERAL1_LARGE,
    EnvironmentVariables: [{Name: MODULE,Value: janusgraph-berkeleyje}],
    PrivilegedMode: true},
    ServiceRole: arn:aws:iam::############:role/cbjanus,
    TimeoutInMinutes: 480
}
1454 [main] ERROR org.janusgraph.codepipelines.AwsCodePipelinesCi  -
PrivilegedMode can only be set for projects with custom or AWS CodeBuild Docker
curated images. (Service: AWSCodeBuild; Status Code: 400;
Error Code: InvalidInputException; Request ID: 89ab67a0-4d00-11e7-8da7-bdeb9326cb3c)
com.amazonaws.services.codebuild.model.InvalidInputException: PrivilegedMode can
only be set for projects with custom or AWS CodeBuild Docker curated images.
(Service: AWSCodeBuild; Status Code: 400;
Error Code: InvalidInputException; Request ID: 89ab67a0-4d00-11e7-8da7-bdeb9326cb3c)

Solution

AWS CodeBuild “Docker” featured images are images that begin with “aws/codebuild/docker”. A full list of selected images from CodeBuild can be found here: http://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref.html .

You can only set this recently introduced flag for your “custom” images. These images may exist in your private Amazon ECR registry or public DockerHub registry. An example of how to enable flags here: http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker-custom-image.html .

So, for your example, you get this error because although the OpenJDK-8 image you are using is a featured image, it is not a “docker” featured image.

Related Problems and Solutions