How do I resolve the error that I receive in AWS CodeDeploy when my deployment times out while waiting for a status callback?

Last updated: 2022-02-09

My AWS CodeDeploy deployment is timing out and returns the following error: "The deployment timed out while waiting for a status callback. CodeDeploy expects a status callback within one hour after a deployment hook is invoked." How do I troubleshoot the issue?

Short description

This issue can occur when you use CodeDeploy to deploy an Amazon Elastic Container Service (Amazon ECS) service with a validation test.

If the test doesn't return a Succeeded or Failed response within 60 minutes after a lifecycle event hook is invoked, then CodeDeploy returns the following error:

"The deployment timed out while waiting for a status callback. CodeDeploy expects a status callback within one hour after a deployment hook is invoked."

Note: The default timeout limit for a lifecycle hook AWS Lambda function's status callback is 60 minutes.

To resolve the error, verify that the lifecycle hook Lambda function has the required method and AWS Identity and Access Management (IAM) permissions.

Resolution

Confirm the cause of the error by reviewing your CloudWatch Logs

Verify that the lifecycle hook Lambda function has the required IAM permissions

Make sure that the lifecycle hook Lambda function has an execution role that includes the following permission: PutLifecycleEventHookExecutionStatus.

Note: The PutLifecycleEventHookExecutionStatus permission isn't included by default in the AWS managed CodeDeployFullAccess IAM policy.

Example PutLifecycleEventHookExecutionStatus permissions statement

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": "codedeploy:PutLifecycleEventHookExecutionStatus",
            "Resource": "*"
        }
    ]
}

Verify that the lifecycle hook Lambda function includes the required method to return a status response to CodeDeploy

Make sure that the lifecycle hook Lambda function includes the putLifecycleEventHookExecutionStatus method.

For more information, see Step 3: Create a lifecycle hook Lambda function in the CodeDeploy User Guide.

Example putLifecycleEventHookExecutionStatus method for a lifecycle hook Lambda function

codedeploy.putLifecycleEventHookExecutionStatus(params, function(err, data) {
     if (err) {
          // Validation failed.
          console.log('AfterAllowTestTraffic validation tests failed');
          console.log(err, err.stack);
          callback("CodeDeploy Status update failed");
     } else {
          // Validation succeeded.
          console.log("AfterAllowTestTraffic validation tests succeeded");callback(null, "AfterAllowTestTraffic validation tests succeeded");
         }

Did this article help?


Do you need billing or technical support?