Skip to content

CodeBuild HTTP 429 Error When Triggered via Lambda/CodebuildTrigger but Works via Console

0

I'm experiencing an intermittent HTTP 429 error in AWS CodeBuild when the build is triggered through a Lambda function. The same build works perfectly fine when manually triggered through the AWS Console.

git fetch failed with exit status 128: POST git-upload-pack 
error: RPC failed; HTTP 429 curl 22 The requested URL returned error: 429
fatal: the remote end hung up unexpectedly
for primary source and source version refs/heads/otg-beta

Permissions

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "codebuild:StartBuild",
                "codebuild:BatchGetBuilds",
                "codecommit:GitPull"
            ],
            "Resource": [
                "arn:aws:codebuild:*:*:project/*",
                "arn:aws:codecommit:*:*:*"
            ]
        }
    ]
}

Enter image description here

asked a year ago401 views

1 Answer
1

The HTTP 429 error you're encountering indicates that you're being rate limited when CodeBuild is trying to access your CodeCommit repository. This is likely happening because the Lambda function is potentially triggering multiple builds in quick succession, causing you to hit API rate limits.

To address this issue, you can try the following approaches:

  1. Implement exponential backoff and retry logic in your Lambda function. This will help spread out the requests and reduce the likelihood of hitting rate limits.

  2. If possible, batch your build requests instead of triggering them individually. This can help reduce the number of API calls made in a short period.

  3. Consider using AWS Step Functions to orchestrate your builds. Step Functions can help manage the flow of your builds and inherently provides some spacing between executions.

  4. Review your CodeBuild project settings to ensure you're not unnecessarily fetching large amounts of data or history that could be contributing to the rate limiting.

  5. If the issue persists, you may need to contact AWS support to request an increase in your API rate limits for CodeCommit or CodeBuild.

Regarding your permissions, the policy you've provided looks correct for starting builds and pulling from CodeCommit. However, you might want to consider making the resource ARNs more specific to your particular projects and repositories for better security practices.

Remember, when triggering builds programmatically, it's important to implement proper error handling and retry mechanisms to deal with transient issues like rate limiting.
Sources
CLIENT_ERROR: Submodule error authorization failed | AWS re:Post
Manage AWS CodeBuild builds with Step Functions - AWS Step Functions
AWSCodeBuildDeveloperAccess - AWS Managed Policy

answered a year ago

EXPERT

reviewed a year 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.