user20358
user20358

Reputation: 14746

.Net Core codebuild issue

I have a .net core project setup on github as the source. I am trying to create and run a build thru the cli.

I used the cli command aws codebuild create-project --generate-cli-skeleton > new-project.json to create the json file required to create a codebuild project. This is what it looks like after I edited the skeleton from the above command.

{
"name": "CoreWebApp-cli-proj",
"description": "created from the CLI",
"source": {
    "type": "GITHUB",
    "location": "https://github.com/xxx-xxx/my-sample.git",
    "gitCloneDepth": 0,
    "gitSubmodulesConfig": {
        "fetchSubmodules": true
    },
    "buildspec": "",
    "auth": {
        "type": "OAUTH",
        "resource": ""
    },
    "reportBuildStatus": true,
    "insecureSsl": true

},
"artifacts": {
    "type": "NO_ARTIFACTS",

    "overrideArtifactName": true,

    "artifactIdentifier": ""
},

"cache": {
    "type": "NO_CACHE",
    "location": "",
    "modes": [
        ""
    ]
},
"environment": {
    "type": "WINDOWS_CONTAINER",
    "image": "aws/codebuild/windows-base:2.0",
    "computeType": "BUILD_GENERAL1_MEDIUM",
    "environmentVariables": [
        {
            "name": "TestVar",
            "value": "TestVarValuehere",
            "type": "PLAINTEXT"
        }
    ],
    "privilegedMode": false,
    "certificate": "arn:aws:s3:::codebuild-bucket/cert/CLI_KeyPair.pem",   

    "imagePullCredentialsType": "CODEBUILD"
},
"serviceRole": "codebuild-admin",
"timeoutInMinutes": 5,
"queuedTimeoutInMinutes": 5,

"tags": [
    {
        "key": "Name",
        "value": "TagName_CodeBuild"
    }
],

"badgeEnabled": true,
"logsConfig": {
    "cloudWatchLogs": {
        "status": "ENABLED",
        "groupName": "CodeBuild-LogGroup",
        "streamName": "CodeBuild-LogStream"
    },
    "s3Logs": {
        "status": "ENABLED",
        "location": "codebuild-bucket/build-log",
        "encryptionDisabled": true
    }
}

}

I then used this command to create the project using the cli aws codebuild create-project --cli-input-json file://new-project.json The project gets created with this command. The problem I encounter is when I am attempting to run this project using the command aws codebuild start-build --project-name CoreWebApp-cli-proj The error I get is:

DOWNLOAD_SOURCE Failed CLIENT_ERROR: unable to install any of the provided certificates for primary source

I have setup the connection between github and my aws account using OAUTH. Why am I still getting the failed to connect error?

I created a separate new project using the console and that works perfectly when I use the start build command from the cli. What is going on and what do I need to check for?

Thanks

Upvotes: 1

Views: 536

Answers (1)

shariqmaws
shariqmaws

Reputation: 8890

I see you are specifying a certificate under environment:

"certificate": "arn:aws:s3:::codebuild-bucket/cert/CLI_KeyPair.pem",

This is only valid for GitHub Enterprise sources as the certificate is used to make trusted SSL connection to the GE repository. Since your source is hosted on https://github.com, there is no need for a custom cert and will likely cause the issue you have witnessed. Can you remove the certificate path and try again.

Secondly, since you have already created a project via Console which works as expected, you can export the project json as:

$ aws codebuild batch-get-projects  --names "CoreWebApp-cli-proj" > CoreWebApp-cli-proj.json

... and then compare the export with the hand-crafted json you shared above to see if you can spot an issue from the differences.

Upvotes: 2

Related Questions