Organizations choose to self-host GitLab Duo capabilities to give teams an AI adoption path without needing to send model requests or inference to infrastructure they do not control. Running models through Amazon Bedrock lets them use approved AWS-hosted models while maintaining control over their inference data, security policies, and compliance requirements.
For an AWS-hosted GitLab Self-Managed instance, the AI Gateway provides the connection between GitLab, Amazon Bedrock, and your AWS environment. It must be configured before administrators can enable and manage these capabilities in GitLab. The gateway runs on AWS EC2, routes model requests to Bedrock, and verifies tokens issued by your GitLab instance. This setup spans four configuration surfaces, each dependent on the others: your GitLab instance, the AWS EC2 host, AWS IAM, and GitLab admin settings.
This guide walks through each surface in order, with a verification check at each step so failures stay locatable.

Confirm two prerequisites on your GitLab instance
- Test HTTPS reachability from outside your network. A curl to
/users/sign_inshould return 200. A certificate error at this point surfaces as a 401 error later. - A runner is registered with the tag gitlab--duo. GitLab Duo Agent Platform flows run as CI/CD pipelines. Without a runner carrying that exact tag, flows queue with no error and no indication that a runner is the problem. Check Admin > CI/CD > Runners and confirm the tag. Register one if it's absent.
Build the gateway on EC2 with bidirectional TLS
The gateway calls back to your GitLab instance at startup to fetch the OpenID Connect (OIDC) discovery document and JSON Web Key Set, and during operation to reach the API. Network rules must allow traffic in both directions to set up the gateway successfully.
- Launch an AWS EC2 instance with Ubuntu Server 24.04 LTS. A t3.small handles GitLab Duo Chat and Code Suggestions. If you plan to run concurrent GitLab Duo Agent Platform workflows, use t3.medium. Multiple workflows can exhaust a 2 GB RAM without warning.
- Install Docker and add 2 GB swap to protect against out-of-memory kills on a small instance.
- Build a TLS bundle that merges public CA certificates with your GitLab instance's root CA. Set both
REQUESTS_CA_BUNDLEandSSL_CERT_FILEto point to this bundle inside the container. The gateway uses two HTTP client libraries that each read a different variable. Setting only one produces TLS failures that don't point back at the missing variable. - Generate four RSA signing keys for JWT authentication.
- Start the container and check the logs. Grep for
CERTIFICATE_VERIFY_FAILED. The health check endpoint returns {} whether TLS trust succeeded or failed, so the log check is the real test.
Grant and verify Amazon Bedrock access
Anthropic Claude models on Bedrock use inference profile IDs, not foundation model IDs. An IAM policy scoped only to foundation-model/* will fail when the gateway resolves a Claude model. Create a policy that covers both foundation-model/* and inference-profile/* in the resource block for InvokeModel. Attach the policy to an IAM role with EC2 as the trusted entity, then assign that role to your instance. Confirm the role is active with aws sts get-caller-identity from the EC2 shell.
Before configuring GitLab, make a direct Bedrock API call using aws bedrock-runtime converse with the inference profile ID you plan to use. A successful call here means any failure in the next step points to GitLab configuration, not AWS. Pass AWS_REGION as an explicit environment variable to the gateway container. The gateway does not read it from instance metadata.
Connect GitLab to the AI gateway
Next, add your gateway IP on Ports 5052 and 50052. Go to Admin > Settings > Network > Outbound requests to make this change. In Admin > GitLab Duo, set the Local AI Gateway URL and raise the request timeout to 300 seconds.
Two timeouts are in play. The one in GitLab admin controls how long GitLab waits for the gateway to respond. The timeout you set on the container controls how long the gateway waits for Bedrock. Both default to values too low for Bedrock on complex prompts, and both need to be raised.
Register the model in Admin > GitLab Duo Self-Hosted using bedrock/ followed by your inference profile ID. Run the connection test. A 400 response at this step almost always means the us. regional prefix is missing from the model identifier.
For more details on any of the above steps, read the GitLab Duo Self-Hosted: AWS Bedrock BYOM Deployment Guide.
Three common setup errors
- Image tag version mismatch. If your instance is at 19.2.4, the tag
self-hosted-v19.2.4-eemay not exist. Check published tags in the ai-assist repository before you start, and use the highest published patch within your minor version. Re-derive the tag after any GitLab upgrade. - Missing or misspelled
gitlab--duorunner tag. The tag requires two hyphens, not one. A wrong tag produces no error message and no timeout warning. Flows queue indefinitely with nothing pointing to a missing or misspelled runner tag. The admin configuration makes flows available, but running them requires the correctgitlab--duotag. Note: The runner authentication token is single use. If a registration fails, create a new runner. - Setting only one CA bundle variable. The gateway uses two HTTP client libraries internally. One reads
REQUESTS_CA_BUNDLE. The other readsSSL_CERT_FILE. Setting only one leaves some code paths without a trusted CA, producing intermittent TLS failures that do not follow a predictable pattern. Both variables must reference the same bundle file. Confirm withsudo docker exec ai-gateway printenv REQUESTS_CA_BUNDLE SSL_CERT_FILE. A blank line in the output means that variable is absent.
With the gateway running, Amazon Bedrock verified, and the common errors listed above ruled out, the infrastructure is ready for use with GitLab Duo Agent Platform.
For feature assignment and end-to-end testing, read Own your AI: Self-Hosted GitLab Duo models with AWS Bedrock.


