2

I set up an AWS CodePipeline that uses github as a source, CodeBuild for build, and deploys to ElasticBeanstalk.

I was able to get it working when everything was set up in the console and I was an admin of the github account (I used a different account for testing)

The actual code I need to deploy belongs to an account where I am not an admin so following this guide I received a Personal Access Token and updated the CodePipeline using the CLI.

Once i updated the project using the cli, it no longer gets triggered when the code is committed.

I'm not sure what changed, because it still doesn't work even when I use the console and set up the webhook directly as an admin of the github account I was testing with.

This is the json I updated the pipeline with:

{
    "pipeline": {
        "roleArn": "arn:aws:iam::xxxxxxx:role/service-role/AWSCodePipelineServiceRole-us-west-2-xxxxx-xxxx", 
        "stages": [
            {
                "name": "Source", 
                "actions": [
                    {
                        "inputArtifacts": [], 
                        "name": "Source", 
                        "actionTypeId": {
                            "category": "Source", 
                            "owner": "ThirdParty", 
                            "version": "1", 
                            "provider": "GitHub"
                        }, 
                        "outputArtifacts": [
                            {
                                "name": "SourceArtifact"
                            }
                        ], 
                        "configuration": {
                            "Owner": "xxx", 
                            "Repo": "xxx", 
                            "PollForSourceChanges": "false", 
                            "Branch": "stage"
                        }, 
                        "runOrder": 1
                    }
                ]
            }, 
            {
                "name": "Build", 
                "actions": [
                    {
                        "inputArtifacts": [
                            {
                                "name": "SourceArtifact"
                            }
                        ], 
                        "name": "Build", 
                        "actionTypeId": {
                            "category": "Build", 
                            "owner": "AWS", 
                            "version": "1", 
                            "provider": "CodeBuild"
                        }, 
                        "outputArtifacts": [
                            {
                                "name": "BuildArtifact"
                            }
                        ], 
                        "configuration": {
                            "ProjectName": "xxx-stage-codebuild"
                        }, 
                        "runOrder": 1
                    }
                ]
            }, 
            {
                "name": "Deploy", 
                "actions": [
                    {
                        "inputArtifacts": [
                            {
                                "name": "BuildArtifact"
                            }
                        ], 
                        "name": "Deploy", 
                        "actionTypeId": {
                            "category": "Deploy", 
                            "owner": "AWS", 
                            "version": "1", 
                            "provider": "ElasticBeanstalk"
                        }, 
                        "outputArtifacts": [], 
                        "configuration": {
                            "ApplicationName": "xxx", 
                            "EnvironmentName": "xxx-stage"
                        }, 
                        "runOrder": 1
                    }
                ]
            }
        ], 
        "artifactStore": {
            "type": "S3", 
            "location": "xxx-artifacts-stage"
        }, 
        "name": "xxx-stage", 
        "version": 15
    }
}

1 Answer 1

3

To fix the webhook for the updated GitHub source, you need to perform the following steps:

  1. Use the steps in [1] to deregister and delete the existing webhook that is associated with the old GitHub repository.

  2. Use the steps in [2] to recreate the webhook.

Ref:

[1] Delete the Webhook for Your GitHub Source - https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-webhooks-delete.html

[2] Create a Webhook for a GitHub Source - https://docs.aws.amazon.com/codepipeline/latest/userguide/pipelines-webhooks-create.html

Let me know if you come across any challenges.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm following the create guide, but i'm getting a 'Not found' error when calling register-webhook-with-third-party. Any idea what could be causing that?
You answer help me on a pipeline built with cdk v2! cdk destroy then cdk deploy fixed the trigger on code commit.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.