How promptfoo runs in AWS CodeBuild for CodeCommit repositories
A team hosting its code in CodeCommit that wants LLM evals or code scans in its pipeline can run promptfoo as a command-line tool inside a CodeBuild job. The build checks out the repository, reads a promptfoo config file stored alongside the application, installs promptfoo, and runs an eval. The job then calls the model provider directly from the build environment, so prompts, test data and model responses travel from the build container to the provider and nowhere else. promptfoo is licensed under the MIT license and its documentation states that it runs completely locally, which is the main point to confirm with your security team before the first run, along with which provider endpoints the build role is allowed to reach.
The AWS integration guide is the documented path for this setup, and it names the build image you need. The CodeBuild Ubuntu image must support Node.js 24, which the guide lists as standard 7.0 or 8.0. Confirm the image version in your project before writing the buildspec, because an older image will fail at the Node.js step rather than at the eval. Provider credentials stay out of the buildspec and the repository. The guide keeps them in Systems Manager Parameter Store or Secrets Manager and exposes them to the job as environment variables, so the people who can edit the buildspec do not automatically gain access to the keys.
The job persists results as JSON and HTML report files, which CodeBuild can keep as build artifacts. Reviewers can open the HTML report from the build, and scripts can read the JSON. Decide early who can download those artifacts, because a report can echo prompts and model outputs that may contain sensitive test data. Code scans have one extra requirement: outside the GitHub Action, a code scan needs a promptfoo API key, which the guide stores as PROMPTFOO_API_KEY in Parameter Store or Secrets Manager. Plan that key with the same care as the provider keys, and check the current scan options in the promptfoo AWS CodeCommit guide before you commit to a design.
What you need before the first CodeBuild run
Most failed first runs trace back to a few missing prerequisites: the build image, the promptfoo version, repository access, IAM permissions, network paths and keys. Work through these cards before you edit the buildspec, and confirm each detail against your own AWS account and network design.
CodeBuild image with Node.js 24
Use an Ubuntu build image from the standard 7.0 or 8.0 image family, since the AWS guide for promptfoo calls for an image that supports Node.js 24. Confirm the exact image identifier available in your Region and account, because image lists change over time. Check the Node.js version the image reports in the first build log before running any eval, so a version mismatch does not surface as a confusing failure later.
AWS CodeCommit guidePinned promptfoo version
Pin the promptfoo version in your build instead of installing whatever is latest, so a release does not change eval behavior between builds. The npm release 0.124.1 requires Node.js 22.22.0 or newer, which the Node.js 24 image satisfies. Record the pinned version in the buildspec and update it deliberately, reading the release notes before each change.
promptfoo on npmCodeCommit repository and branch access
Decide which CodeCommit repositories and branches the build will read, and confirm that the CodeBuild project can clone them through its service role. Pull request events need the build to be triggered from the repository, so confirm how your team wants trigger filters set for pull requests and main branch pushes. Check that the prompt files, test configs and datasets the eval uses are stored in the repository or fetched from a location the build can reach.
IAM service role for secrets
The CodeBuild service role needs permission to read the provider keys from Systems Manager Parameter Store or Secrets Manager, and to write build artifacts to the location you choose. Grant read access only to the specific parameter paths or secret ARNs the build uses, and scope KMS decrypt permissions to the key that protects them. Confirm the exact policy statements in your own account with your AWS administrators, since account-level guardrails may change what works.
Outbound network paths
If the build runs inside a VPC, confirm it can reach the model provider endpoints your evals call. When code scans are used, it must also reach the promptfoo API, so check outbound rules, NAT gateways, proxies and any DNS or firewall policy that blocks those hosts. Test connectivity from a throwaway build before the first real run, and confirm the required hostnames with your network team and the provider documentation.
promptfoo API key for code scans
Code scans run outside the GitHub Action need a promptfoo API key, which the AWS guide stores as PROMPTFOO_API_KEY in Parameter Store or Secrets Manager. Plain evals that only call your model provider do not need this key, so do not add it to every project by default. Confirm with your security team who owns the key, how it is rotated and which projects are allowed to use it, and read the promptfoo pricing page to understand what your plan includes.
promptfoo pricingConfiguring the buildspec, keys and reports step by step
This sequence takes a CodeCommit repository from an empty CodeBuild project to a pull request build that runs promptfoo evals, stores its keys securely and keeps the JSON and HTML reports as downloadable build artifacts. Each step ends with a check you can run before moving on.
Create the CodeCommit repository and build project
A platform engineer creates the CodeCommit repository that holds the prompts, promptfoo configuration and test cases, then creates a CodeBuild project pointed at it. Select an Ubuntu managed image that supports Node.js 24, using standard 7.0 or 8.0 as the AWS guide specifies, and give the project a service role that can read the repository and write logs. Confirm the image choice against the current CodeBuild console, since image names change over time. The step is done when a manual start of the project with a placeholder buildspec completes successfully and shows the expected Node.js version in its logs.
Store provider and promptfoo keys securely
Store the promptfoo API key as PROMPTFOO_API_KEY, along with each model provider key your eval configuration calls, in either Systems Manager Parameter Store or Secrets Manager. Use SecureString parameters or secrets, and grant the CodeBuild service role read access only to those specific resources. Do not place keys in the buildspec, environment variables typed into the project, or the repository. The step is done when a throwaway test build prints only the length of a decrypted value, confirming the variable resolves without exposing the key in logs.
Reference the secrets in the buildspec
Add the secret references to the buildspec.yml under the env section, using the parameter-store or secrets-manager keys so CodeBuild resolves them at build start. Keep the variable names identical to the ones promptfoo reads, so the eval configuration does not need changes for each environment. The platform engineer should also confirm that the buildspec runs the install phase with a pinned promptfoo version rather than an unversioned install. The step is done when the build log shows the variables are present by name and the build still passes with no secret values printed.
Add the eval command with JSON and HTML output
In the build phase, run promptfoo eval against the configuration in the repository and write results to fixed paths, one JSON file and one HTML file, using the output options described in the promptfoo documentation. Choose a directory such as a dedicated reports folder so the artifact paths stay predictable. Decide in advance whether a failing eval should stop the build or let the reports upload first, because that choice controls whether reviewers can see results from failed runs. The step is done when a local or test build writes both files into the reports folder with the expected names.
Declare the report paths as build artifacts
Add an artifacts section to the buildspec that lists the JSON and HTML report paths, and set the files to upload even when the eval step returns a non-zero exit code. CodeBuild stores artifacts in the S3 location configured on the project, so confirm that bucket's access policy and retention meet your organization's rules for prompt and response data. The reports can contain test inputs and model outputs, so treat them as sensitive. The step is done when the build detail page lists the artifact and the downloaded HTML report opens and shows the eval results.
Wire the pull request trigger
Configure a webhook or filter group on the CodeBuild project so that pull request events on the target branch start a build, and restrict the filter to the events your review process needs. Pull requests from forks are not a CodeCommit concern in the usual way, but confirm which principals can open pull requests, since those users trigger builds that spend provider credits. The step is done when opening a test pull request starts a build automatically, the build result appears on the pull request, and the artifacts are linked from the build.
Confirm the failure path and reviewer access
Force a deliberate eval failure on a test branch and confirm that the build status turns to failed, the reports still upload, and reviewers with pull request access can reach the artifacts without holding administrator rights on the AWS account. Record which role grants artifact download and which grants secret read, and keep those roles separate. The step is done when the failing build, its reports and the permission checks are documented in the team runbook, so the first real regression is handled the same way.
Choosing how results reach reviewers
The simplest option has CodeBuild run promptfoo, write the JSON and HTML reports, and save them as build artifacts. Reviewers open the artifacts from the build details page when they want to inspect a run. Nothing in the repository or the pull request changes automatically, so this option depends on someone remembering to look. It suits a first rollout, where the team is still learning what a normal run looks like and which assertions produce noise.
- What it needs: an
artifactssection in the buildspec that names the report files, plus a clear output path so the files are not overwritten by later steps. - What it cannot do: tell a reviewer that a result exists, or block a merge on its own.
- Retention: artifacts follow the retention settings of the CodeBuild project, so confirm how long they are kept.
- Sensitive content: reports can include prompts and model outputs, so confirm who can read the artifact bucket.
Before relying on this option, check which artifact settings the AWS guide describes and confirm them against your own project configuration.
This option reports the outcome of the run back to the pull request, so a reviewer sees that evals ran and whether they passed without opening the build. CodeCommit pull requests can show the result of a build, and CodeBuild can report status for a run. Whether a promptfoo summary appears as a comment is not something this guide confirms, so treat any comment behavior as something to verify with the AWS guide and your own tooling rather than assume it exists.
- What it needs: a build triggered by pull request events, and a way to post a status or a comment, such as a script that calls the CodeCommit API with a token that has the required permissions.
- What it cannot do by default: show the full report inside the pull request, since reviewers still need a link to the artifacts or a hosted location.
- Permissions: the build role needs rights to read the repository and write pull request activity, so review those grants against least privilege.
- Noise: frequent comments on every push can train reviewers to ignore them, so decide what gets posted.
Confirm the exact trigger and status options in your CodeBuild and CodeCommit settings before you design the integration.
A gate makes the build fail when the eval results fall below an agreed level, so a regression blocks the change from moving forward. promptfoo reports pass and fail results, and the build step can use the exit status or a threshold to decide the outcome. The gate is the only option here that enforces quality, and it is also the one most likely to block work when a model-graded check behaves inconsistently.
- What it needs: a defined threshold agreed by the team, a failing exit code when the threshold is missed, and tests that are stable enough to trust.
- What it cannot do: explain why a test failed. Reviewers still need the report to decide whether a failure is a real regression.
- Flaky checks: model-graded assertions can vary between runs, so a strict gate may fail for reasons unrelated to the change.
- Ownership: someone must decide who can override a failed gate and how that decision is recorded.
Confirm the threshold mechanism your promptfoo version supports and test the gate on a branch before making it required.
Most teams end up using all three layers, but they add them in order. Artifacts come first because they give reviewers the evidence. Pull request status comes next so the result is visible at review time. The gate comes last, once the team trusts the results enough to let them block a merge. Moving through these stages lets the team tune assertions and cost before the stakes rise.
- Start with artifacts: collect a few runs and check whether the reports are useful.
- Add status reporting: surface the outcome where reviewers already work.
- Introduce the gate on non-critical branches: observe failure rates before it is required.
- Separate required and advisory checks: keep unstable checks advisory so they do not block every merge.
- Record overrides: log who approved a failed gate and why.
Before you choose, check the current AWS guide and confirm how status, comments and artifacts behave in your account.
Mapping secrets, variables and outputs between CodeBuild and promptfoo
This table shows where each value comes from in a CodeBuild run and where promptfoo reads or writes it. Read each row as a handoff: the source on the left feeds the promptfoo setting on the right, and the last column names the authority for that mapping. The main takeaway is that keys belong in Parameter Store or Secrets Manager, never in the buildspec or the repository.
| Value | Where it is set in CodeBuild | What promptfoo uses it for | Source of the mapping |
|---|---|---|---|
| Provider API keys | Parameter Store or Secrets Manager, exposed as environment variables | Authenticating to the model providers under test and grader models | promptfoo AWS CodeCommit docs |
| PROMPTFOO_API_KEY | Parameter Store or Secrets Manager, exposed as an environment variable | Sending code scan results to the promptfoo platform, which the GitHub Action handles without it | promptfoo AWS CodeCommit docs |
| Node.js runtime | buildspec runtime-versions set to Node.js 24 on an Ubuntu standard image 7.0 or 8.0 | Running the promptfoo CLI, which needs a supported Node.js version | promptfoo AWS CodeCommit docs; promptfoo npm release notes |
| Eval config path | Relative path to the config file committed in the CodeCommit repository | Selecting the suite that promptfoo eval runs | Repository layout chosen by your team |
| JSON report output | Build artifact path declared in the buildspec artifacts section | Writing machine-readable results for scripts and later review | promptfoo AWS CodeCommit docs |
| HTML report output | Build artifact path declared in the buildspec artifacts section | Writing a human-readable report reviewers can open from the build | promptfoo AWS CodeCommit docs |
| Branch or commit identifier | CodeBuild source version variables, passed into the report file name | Keeping reports from different branches and commits separate | CodeBuild environment variables; naming convention set by your team |
Hardening the CodeBuild role, keys and report contents
A CodeBuild job that runs promptfoo touches three things worth protecting: the IAM role that reads parameters, the promptfoo and provider keys, and the reports the job leaves behind. The cards below cover each one, plus the edition limits that affect who can review results.
Scope the build role to named parameters
The CodeBuild service role should read only the specific Parameter Store paths or Secrets Manager secrets that the promptfoo job needs, not a wildcard over the account. Grant read actions on those exact resource ARNs, and keep CodeCommit access limited to the repository the job builds. Review the role whenever a new provider is added, because each new key is a new permission. Illustrative check: a job that scans one repository should not be able to read the keys for an unrelated pipeline.
AWS CodeCommit guideEncrypt secrets with a KMS key
Parameter Store SecureString values and Secrets Manager secrets are encrypted with AWS KMS, so the role that reads them also needs decrypt permission on the specific key. Use a customer managed key where your policy requires control over key rotation and key policy, and confirm which key the parameter or secret actually uses. Ask your security team who can administer that key, because key administrators can effectively grant or revoke access to every secret it protects.
Keep secret values out of build output
A buildspec that runs echo $PROMPTFOO_API_KEY or prints the full environment will write the key into the CodeBuild log, and logs are often readable by more people than the secret. Pass secrets through the buildspec env configuration, avoid set -x around commands that use them, and confirm that promptfoo's debug output does not print provider headers in your version. Review a sample build log before the pipeline goes into regular use.
Restrict who reads build artifacts
Reports from a promptfoo run can contain the prompts, test inputs, model outputs and red team attack payloads that the run used. Store artifacts in an S3 bucket with restricted read access, enable encryption, and set a lifecycle rule that matches your retention policy. Confirm with your security team whether the reports fall under a data classification that limits who may see them, since the same content may appear in build logs and pull request comments.
Limit the promptfoo API key to code scanning
Outside the GitHub Action, code scanning run through the CLI needs a promptfoo API key, stored as PROMPTFOO_API_KEY. Give the job only the key it needs for code scanning, keep it separate from model provider keys, and store it under its own parameter so it can be rotated without touching provider credentials. Ask your team who owns the key and how revocation works if a build log or artifact is exposed.
Plan access for reviewers
Community edition is free and includes all LLM evaluation features and red teaming with 10k probes per month, but it comes with community support and has no team sharing, SSO or role-based access control. If reviewers outside the build account need governed access to results, those controls belong to the Enterprise edition, which uses custom pricing. Decide before rollout whether CodeBuild artifacts and pull request comments are the review path, or whether a paid edition is needed.
Promptfoo pricingWhere the build, the model provider and promptfoo exchange data
The first thing to settle is which data leaves your network in each part of this pipeline, because the answer differs for evals and for code scans. CodeCommit holds the repository, and CodeBuild pulls the code, runs the promptfoo eval command and holds the provider keys for the duration of the build. The model provider receives the test prompts that the build sends, and those prompts are often built from your system prompts, retrieval content or sample customer records. Treat the build role's network path to the provider as a data flow you must document, not as an internal detail.
The promptfoo documentation states that the software runs locally: evals run on your machine and talk directly with the LLM. Read that as a statement about where the eval logic runs, not as a promise about where your data goes. In CodeBuild, the build container is the "your machine" in that sentence, so the outbound path is the one your security team will review. Confirm, for each provider you configure, whether requests go to a public endpoint, a private endpoint inside your cloud account or a self-hosted server, and record the answer next to the provider entry in your build design.
Code scans are different. Outside the GitHub Action, a code scan needs a promptfoo API key, which this guide stores as PROMPTFOO_API_KEY in Parameter Store or Secrets Manager, so scan data is sent to the promptfoo API. Confirm with promptfoo exactly what a code scan transmits, how long it is retained and whether your agreement covers it, before you enable scans on repositories that contain regulated or confidential code. The promptfoo AWS CodeCommit integration docs are the place to start that check.
How a commit becomes a reviewable promptfoo report
The flow starts when a developer pushes to a CodeCommit branch and a pull request triggers CodeBuild. The build runs on an Ubuntu image with Node.js 24, pulls provider keys and the promptfoo API key from Parameter Store or Secrets Manager, and runs the eval and code scan. Model calls go to the provider you configured, while the code scan reaches the promptfoo API, so check which hosts the build role can reach. JSON and HTML reports are saved as build artifacts that reviewers open from the build, and the build status is reported back to the pull request.
Commit, build, credentials, model calls, reports and pull request status.
Why the first CodeBuild run of promptfoo fails
This table lists the failures most likely to stop a first promptfoo run in AWS CodeBuild, with the cause and fix for each. Work down the rows in order when a build fails, since a missing key or blocked network call often looks like a model error. Confirm each fix against your own project settings before changing the pipeline.
| Failure | Likely cause | Fix |
|---|---|---|
| Unsupported Node.js version | The build image does not provide Node.js 24, which the promptfoo AWS guide expects on an Ubuntu standard image (7.0 or 8.0). | Select an Ubuntu standard image version that supports Node.js 24, then print node --version as the first build step. |
| Missing IAM permission to read parameters | The CodeBuild service role cannot call ssm:GetParameter or secretsmanager:GetSecretValue for the stored provider keys. | Grant read access to the specific parameter or secret ARNs, and confirm the key policy allows decryption if a customer managed KMS key is used. |
| Keys not exported to the build environment | The buildspec does not reference the parameters or secrets, so PROMPTFOO_API_KEY and provider keys are empty when promptfoo runs. | Map each parameter or secret under env in buildspec.yml, then check the variable names match what the promptfoo config reads. |
| Build timeouts on large suites | The eval or red team run takes longer than the project's build timeout, often because concurrency is low or the response cache is empty. | Raise the project timeout to fit the suite, split large configs into smaller runs, and check the promptfoo cache is restored between builds. |
| Artifact paths do not match output files | The artifacts section points to a directory or file name that promptfoo did not write, such as a different output path than the one set in the eval command. | Set an explicit output path in the eval command and copy the same path in the buildspec artifacts section, then inspect the build logs for where the files were written. |
| Outbound network blocked from a VPC-attached project | The project runs inside a VPC with no route to the internet or to the model provider endpoint, so provider calls fail. | Add a NAT gateway or an approved egress path for the provider endpoints, or confirm with your network team which destinations the subnets may reach. |
| Missing PROMPTFOO_API_KEY for code scans | Code scanning outside the GitHub Action needs a promptfoo API key, and the key was not stored or not mapped into the build. | Store PROMPTFOO_API_KEY in Parameter Store or Secrets Manager, map it into the buildspec env block, and confirm the scan step runs only after it is set. |
Questions teams ask before running promptfoo in CodeBuild
How much does it cost to run promptfoo in CodeBuild?
The promptfoo software is MIT licensed, and the Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month. Your recurring costs are the AWS build minutes for each run, the model API spend for each eval and grader call, and any storage for reports. Build minutes and API spend grow with the number of pipeline stages, the size of your eval suites and how often they run on every commit. Ask any partner for a quote built from a written scope that states the stages, suite sizes and run frequency, so the figure can be checked against your own usage.
Do we need to pay for promptfoo Enterprise to use it in CodeBuild?
No. The guide's approach runs promptfoo eval in a CodeBuild job, and the Community edition covers that use. Enterprise adds team sharing, teams-based access control and SSO, custom roles, continuous monitoring and priority support with SLAs. Enterprise is sold at custom pricing, so there is no published figure to plan around. Ask the vendor for a quote if you need those features, and confirm whether your use case needs them before you commit.
What Node.js version does the CodeBuild image need?
The promptfoo AWS guide requires a CodeBuild Ubuntu image that supports Node.js 24, using the standard 7.0 or 8.0 image. The npm release 0.124.1 requires Node.js 22.22.0 or newer, so confirm the exact image and runtime against the current guide and release notes before you set up the project. Choosing an older image is a common cause of a first-run failure, and the fix is a change to the project environment, not to the eval suite.
How long does the setup take?
Setup time depends on how many pipelines you have, whether provider keys are already in Parameter Store or Secrets Manager, how many eval suites need to run and whether reports must be persisted as build artifacts. A single project with one eval suite and existing secrets is usually the shortest path. Teams with several repositories, separate staging and production model endpoints, or pull request gating need more time for testing and review. No duration is fixed in this guide, so ask for a timeline that is tied to a written scope.
What does our team need to provide before the work starts?
Your team needs an AWS account with a CodeCommit repository, permission to create CodeBuild projects and IAM roles, and access to Systems Manager Parameter Store or Secrets Manager. You also need the provider API keys for each model under test and, for code scanning outside the GitHub Action, a promptfoo API key stored as PROMPTFOO_API_KEY. Agree on who approves changes to the build spec and who owns the eval suites, because those decisions shape the ongoing effort.
Can our internal team set this up alone?
Often yes, if you have an engineer comfortable with CodeBuild buildspec files, IAM and secrets handling, and the eval configuration. The harder parts are usually the eval suite design, deciding which failures should block a merge, and keeping provider keys and report contents under your data handling rules. If those skills are missing or the team is small, an outside partner can take the work as a fixed-scope engagement with agreed deliverables and a written timeline.
What should a written scope for an outside quote include?
A useful scope lists the repositories and branches in scope, the number of CodeBuild projects and pipeline stages, the eval and red team suites to run and how often, the providers and secrets to wire up, the artifacts and reports to keep, and who receives the handover. It should also name what is excluded, such as writing new eval cases or Enterprise features. DeployOpen plans and delivers work under a written scope agreed before the work starts, so a quote follows from that document rather than from a generic price list.
How DeployOpen scopes and delivers a promptfoo CodeBuild integration
DeployOpen plans and builds the CodeBuild setup for promptfoo around your CodeCommit repositories, your provider keys and your review workflow, inside your own AWS accounts. Each engagement starts with a written scope, so you know what is built, tested, documented and handed over before work begins.
How we scope
- We confirm which repositories, branches and prompt files trigger promptfoo eval runs in CodeBuild.
- We agree which provider keys go into Parameter Store or Secrets Manager and who owns them.
- We record whether the scope includes red team scans, code scanning and report publishing in pull requests.
How we build
- We configure a CodeBuild Ubuntu image that supports Node.js 24, checking the image version against current AWS documentation.
- We wire PROMPTFOO_API_KEY and provider credentials from Parameter Store or Secrets Manager, never from plain buildspec text.
- We test failing runs, pass-rate thresholds and JSON and HTML report artifacts before the pipeline is accepted.
How we hand over
- You receive the buildspec, IAM policies, secret paths and a runbook describing each pipeline stage.
- We document how reports are stored as build artifacts and how pull request comments are posted and reviewed.
- We walk your engineers through a test run and a deliberate failing change so they can reproduce the outcome.
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- Ongoing support, promptfoo upgrades and continuous testing are available as a retainer.
- Ask any provider to confirm the AWS, promptfoo and model-provider details that apply to your own environment.

