Showing posts with label DevOps. Show all posts
Showing posts with label DevOps. Show all posts

Monday, 13 July 2026

[Solved] CodeBuild "Internal Service Error" - Fix Region-Wide Provisioning Failures

AWS CodeBuild internal service error fix diagram

The error "Internal Service Error: CodeBuild is experiencing issues" can show up even when nothing in your own pipeline configuration has changed. This guide walks through how we diagnosed a region-wide CodeBuild failure and what actually fixed it.

The error "Internal Service Error: CodeBuild is experiencing issues" can show up even when nothing in your own pipeline configuration has changed. This guide walks through how we diagnosed a region-wide CodeBuild failure and what actually fixed it.

Internal Service Error: CodeBuild is experiencing issues

What Causes This Error?

This error typically occurs when:

  • A source credential (Bitbucket/GitHub/GitLab) connected to your account has become corrupted
  • The credential was re-imported or re-authorized multiple times in a short window
  • CodeBuild's provisioning step fails while validating account-level source connections
  • The issue is regional rather than tied to any single project

Step 1 - Rule Out Your Own Configuration First

Before assuming an AWS-side fault, check the usual suspects:

# Check recent changes to compute fleets
aws codebuild list-compute-fleets --region us-east-2

# Check recent changes to build images / VPC config on a project
aws codebuild batch-get-projects --names <project-name> --region us-east-2

If none of these have changed and the failure is affecting multiple unrelated projects at the same time, the issue is likely outside your project configuration.

Step 2 - Isolate With a Minimal Test Project

Create a brand-new CodeBuild project with no custom VPC, no custom image, and no dependencies — just the defaults:

aws codebuild create-project \
  --name test-region-diagnostic \
  --source type=NO_SOURCE \
  --artifacts type=NO_ARTIFACTS \
  --environment type=LINUX_CONTAINER,image=aws/codebuild/standard:7.0,computeType=BUILD_GENERAL1_SMALL \
  --service-role <role-arn> \
  --region us-east-2

If this minimal project fails with the same error, run the identical test in a different region:

aws codebuild create-project \
  --name test-region-diagnostic \
  --source type=NO_SOURCE \
  --artifacts type=NO_ARTIFACTS \
  --environment type=LINUX_CONTAINER,image=aws/codebuild/standard:7.0,computeType=BUILD_GENERAL1_SMALL \
  --service-role <role-arn> \
  --region us-east-1

If the same project succeeds in one region and fails in another, the problem is scoped to the account in that specific region — not your pipeline.

Step 3 - Check Source Credential History

Region-wide CodeBuild provisioning failures are often traced back to a corrupted source credential. Check how many times it's been re-imported recently:

aws codebuild list-source-credentials --region us-east-2

If a credential has been re-imported several times in a short window (especially across different auth types — OAuth, access token, basic auth), that repeated re-import can corrupt its internal storage and break provisioning for every project in the region, even ones that don't use that credential.

Step 4 - Fix: Delete and Re-Save the Credential

  1. Open the CodeBuild console
  2. Go to Settings → Source credentials
  3. Delete the corrupted credential
  4. Re-save a freshly generated access token for the same source provider

No redeploys or infrastructure changes are needed — this is purely an account-level credential fix.

Step 5 - Confirm the Fix

Check the FailedBuilds metric after the fix to confirm builds are succeeding again:

aws cloudwatch get-metric-statistics \
  --namespace AWS/CodeBuild \
  --metric-name FailedBuilds \
  --region us-east-2 \
  --start-time 2026-07-10T00:00:00Z \
  --end-time 2026-07-11T00:00:00Z \
  --period 3600 \
  --statistics Sum

A flat zero across the period confirms the region has recovered.

Quick Summary

StepCommand / Action
Check project configaws codebuild batch-get-projects --names <project>
Create minimal testaws codebuild create-project --source type=NO_SOURCE ...
Compare across regionsRun the same test project in a second region
Check credential historyaws codebuild list-source-credentials
FixConsole → Settings → Source credentials → delete & re-save token
Verifyaws cloudwatch get-metric-statistics --metric-name FailedBuilds

If you're seeing this error and none of your own configuration has changed, check your account's source credential import history before assuming it's a broader AWS outage — a single corrupted credential can silently break every CodeBuild project in a region.

Wednesday, 8 July 2026

How to Configure Apache Microcache for Drupal?

Configure Apache Microcache

Apache HTTP Server, commonly known as Apache, is a widely used open-source web server. Caching is an essential aspect of web server optimization — it can significantly improve response time and reduce load on the server. “Apache Microcache” typically refers to a small, quickly-accessible cache used to improve performance, often for a short TTL on top of an origin that would otherwise be hit on every request.

Here are the general steps to configure an Apache Microcache in front of Drupal.

1. Enable mod_cache and the disk cache module

Make sure the caching modules are loaded in your Apache configuration:

sudo nano /etc/httpd/conf/httpd.conf

# Ensure mod_cache is loaded:
LoadModule cache_module modules/mod_cache.so

# Load the disk cache backend. The module name/file depends on your Apache version:
#   Apache 2.4+ (current):  mod_cache_disk  ->  modules/mod_cache_disk.so
#   Apache 2.2 (legacy):    mod_disk_cache  ->  modules/mod_disk_cache.so
LoadModule cache_disk_module modules/mod_cache_disk.so

Version note: mod_disk_cache was renamed to mod_cache_disk in Apache 2.4. Check httpd -v first, and match the LoadModule line, the .so filename, and the <IfModule> guard below to whichever version you’re actually running — mixing the 2.2 and 2.4 names is a common cause of “module not loaded” errors.

2. Configure mod_cache and the disk cache

Below is a baseline configuration tuned for Drupal. Adjust it for your own traffic patterns and site structure; other CMSs will need different CacheDisable paths and TTLs.

<IfModule mod_cache.c>
  # Turn off CacheQuickHandler so requests still pass through
  # other output filters (needed for compression below).
  CacheQuickHandler Off

  # Cache headers off by default; enable only for debugging.
  CacheHeader Off
  CacheDetailHeader Off

  # Cache responses even without a Last-Modified header.
  CacheIgnoreNoLastMod On

  # Cache expiry (seconds).
  CacheDefaultExpire 180
  CacheMinExpire 5
  CacheStoreExpired Off
  CacheLastModifiedFactor 0.5

  # Ignore upstream cache-control so short TTLs above take effect.
  CacheIgnoreCacheControl On
  CacheIgnoreHeaders Set-Cookie Cookie

  # Avoid stampedes / stale serving during revalidation.
  CacheLock On
  CacheLockMaxAge 5

  # Never cache the admin area.
  CacheDisable /admin

  # GZIP compression on cached output.
  SetOutputFilter CACHE
  AddOutputFilterByType DEFLATE text/html text/plain text/css \
                        application/javascript \
                        application/rss+xml \
                        text/xml image/svg+xml

  # Disk cache backend.
  <IfModule mod_cache_disk.c>
    # Adjust CacheRoot to a writable path on your server.
    CacheRoot /var/cache/httpd/proxy/
    CacheEnable disk /
    CacheDirLevels 2
    CacheDirLength 1
    CacheMaxFileSize 20000000
  </IfModule>
</IfModule>

Adjust CacheRoot to point to the directory where you want cached data stored, and make sure that directory is writable by the Apache user (chown -R apache:apache /var/cache/httpd/proxy/ or the equivalent for your distro).

3. Save and restart Apache

sudo systemctl restart apache2
# or, on RHEL/CentOS-based systems:
sudo systemctl restart httpd

Things to watch for on a real Drupal deployment

  • Authenticated sessions: CacheIgnoreHeaders Set-Cookie Cookie means Apache will happily cache a response even when a session cookie is present. Pair this with CacheDisable on any authenticated paths (/user, /admin, /node/*/edit, etc.) or you risk serving one user’s personalized page to another.
  • Cache purging: this config has no active purge/ban mechanism — it’s TTL-based only. If you need instant invalidation on content edits, this microcache approach isn’t a substitute for something like Varnish with BAN support; it’s meant as a lightweight buffer for anonymous traffic spikes.
  • Disk I/O: mod_cache_disk writes to local disk, so on multi-node/ECS-style deployments each container gets its own cache — there’s no shared cache state across tasks unless CacheRoot points at a shared volume (and even then, disk cache isn’t designed for concurrent multi-writer access).

That’s it — you’ve configured an Apache Microcache in front of Drupal.