Skip to content

Failed to create webhook. Repository not found or permission denied. Please make sure the source credentials associated with your project have the permission to create webhook. Service: AWSCodeBuild;

0

I'm getting this error trying to create a CodeBuild project in CDK:

AWS::CodeBuild::Project | ImageBuildProject (ImageBuildProject74D885BB) Failed to call CreateWebhook, reason: Failed to create webhook. Repository not found or permission denied. Please make sure the source credentials associated with your project have the permission to create webhook. (Service: AWSCodeBuild; Status Code: 400; Error Code: OAuthProviderException; Request ID: ...

This is just a plain CDK CodeBuild construct not part of a CDK Pipeline (I use that too but somewhere else, this error is just on CodeBuild by itself).

My GH repo is in a (free) Org, do I need to move it back to a Personal repo to make it work? I couldn't find a place in the GH UI to create a PAT. Also tried CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION from some documentation. Nothing is working :-/

2 Answers
0

The error you're encountering suggests that there's an issue with the permissions or access to the GitHub repository when trying to create a webhook for your CodeBuild project. This can happen for several reasons, especially when dealing with repositories in GitHub organizations.

Here are a few things to consider:

  1. GitHub Organization Permissions: If your repository is in a GitHub organization, CodeBuild may need additional permissions to create webhooks at the organization level. This is not necessarily related to whether the organization is free or paid.

  2. OAuth Token Permissions: If you're using an existing OAuth connection, it may not have the necessary permissions to create organization-level webhooks. You might need to regenerate the connection in the CodeBuild console to grant these permissions.

  3. Manual Webhook Creation: As an alternative, you can create the webhook manually using CodeBuild's manual webhooks feature. This allows you to set up the webhook in GitHub yourself, bypassing the automatic creation process.

  4. GitHub App Connection: Consider using a GitHub App connection instead of OAuth. This can provide more granular control over permissions and may resolve the issue.

  5. IAM Role Permissions: Ensure that the IAM role associated with your CodeBuild project has the necessary permissions to create webhooks.

To address this issue:

  1. Check the OAuth token's permissions in GitHub and ensure it has access to the organization and repository.

  2. If possible, try regenerating the OAuth connection through the CodeBuild console.

  3. Consider setting up a manual webhook. You can obtain a Payload URL and Secret value from CodeBuild during project creation and use these to manually create the webhook in GitHub.

  4. If using CDK, you might need to adjust your construct to use manual webhook creation or provide the necessary permissions.

  5. Verify that the IAM role associated with your CodeBuild project has the required permissions to interact with GitHub and create webhooks.

Moving the repository to a personal account is not necessarily required and may not solve the issue if it's related to permissions or configuration. Instead, focus on ensuring the correct permissions are in place for the organization repository.

If the issue persists, you may need to review the GitHub organization settings, check for any restrictions on third-party access, or consult with your organization's GitHub administrators to ensure CodeBuild has the necessary access.
Sources
Filter GitHub global or organization webhook events (console) - AWS CodeBuild
GitHub App connections for GitHub and GitHub Enterprise Server - AWS CodeBuild
GitHub manual webhooks - AWS CodeBuild

answered 2 years ago

  • I see an "AWS Connector for GitHub" under the org, and it has Read and Write privs. I don't seen an option for Admin.

0

You do not need to move the repository from the GitHub organization to a personal account. The organization's free plan is not the deciding factor.

The Read and write summary shown for AWS Connector for GitHub is not the same thing as approval of a newly requested webhook permission. The current CodeBuild troubleshooting guide specifically says that, when a connection reports missing repository access or webhook creation errors, the installed GitHub App can be waiting for its updated webhook permission to be reviewed and accepted.

Ask a GitHub organization owner to check the installed AWS Connector for GitHub app and verify:

  1. The installation has access to this repository (or all repositories, if that is the organization's intended policy).
  2. Any newly requested webhook permission is reviewed and accepted.
  3. The app is still authorized, installed, and not suspended.

If the previous GitHub App installation was removed and later reinstalled, AWS documents that reinstalling the app does not revive the connection associated with the old installation; create a new CodeConnections connection in that case.

If this CodeBuild project uses a CodeConnections connection, also verify that the project service role can call codeconnections:GetConnection and codeconnections:GetConnectionToken for that connection. If the project instead uses an OAuth app, PAT, or Secrets Manager credential, confirm that the CodeBuild source credential belongs to an identity that can access this organization repository; these are separate credential types.

CODEBUILD_DEFAULT_WEBHOOK_SOURCE_LOCATION is the required source location for a scoped organization or global webhook. It is not a GitHub credential and does not grant repository or webhook permission, so changing the source location alone cannot resolve this authorization error for a repository webhook.

After those checks, redeploy the CDK stack or recreate the webhook. If it still fails, compare the repository owner/name in the CodeBuild source configuration with the repositories selected in the GitHub App installation. Redact connection ARNs, tokens, and organization-specific security settings from diagnostic material.

Official references:

answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.