---
title: How do you find AI agents running in serverless functions?
url: https://opencontroller.lyzr.com/blog/find-ai-agents-in-serverless-functions
published: 2026-11-15
updated: 2026-11-15
author: Lyzr
---

# How do you find AI agents running in serverless functions?

**Check four things on every function: environment variables or secrets that hold model API keys, packages or layers that include LLM and agent SDKs, execution roles or identities allowed to invoke models, and outbound traffic to model provider endpoints. Most of this can be read from cloud APIs without opening the code, so you can scan every account and subscription on a schedule.**

Serverless functions are a favourite home for small agents. A team wires a Lambda to a queue, adds a few lines that call a model, and has an agent triaging tickets by lunchtime. It never passes through an architecture review, and it may hold a personal API key.

## Why are serverless agents hard to see?

- There are many of them. Large estates run thousands of functions across accounts and regions.
- They are short-lived, so host-based tools never see them.
- They often call external model APIs directly, bypassing any internal gateway.
- They share execution roles, so one role's model permission can hide many agents.
- Triggers such as queues, schedules and webhooks make them act without a user present.

## What signals work on each platform?

| Signal | AWS Lambda | Azure Functions | Google Cloud Run functions |
|---|---|---|---|
| Model keys in configuration | Environment variables | App settings | Environment variables, Secret Manager references |
| SDK packages | Deployment package and layers | Deployment package | Source or container image |
| Model permissions | Execution role allowing `bedrock:InvokeModel` | Managed identity with roles such as Cognitive Services OpenAI User | Service account with Vertex AI roles |
| Triggers | Event source mappings, schedules, function URLs | Triggers and bindings | Event triggers, HTTP |
| Model calls in logs | CloudTrail Bedrock events | Azure Monitor and resource logs | Cloud Audit Logs |

## How do you run the scan?

1. **Enumerate functions** in every account, subscription, project and region. Missing regions is the most common gap.
2. **Read configuration.** Pull environment variable names and app settings. Flag names such as `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `AZURE_OPENAI_ENDPOINT` or anything containing `LLM`, `GPT` or `MODEL`. Record names, not values, in your findings.
3. **Inspect identities.** For each execution role, managed identity or service account, check whether it can invoke models. A role with `bedrock:InvokeModel` on `*` is a finding in itself.
4. **Check packages.** List layers and dependencies, or scan the source repository, for SDKs such as `openai`, `anthropic`, `google-genai`, `langchain`, `langgraph` and `crewai`; see [finding AI agents in source code](/blog/find-ai-agents-in-source-code).
5. **Map triggers.** Note what starts the function and whether it can be called from the internet.
6. **Correlate with logs.** Match model invocation events and egress to provider domains back to functions; see [detecting unapproved LLM API traffic](/blog/detect-unapproved-llm-api-traffic).
7. **Assign an owner** from tags, deployment pipeline metadata or the account owner.

The read permissions this needs are modest. Our guide to [AI agent discovery permissions on AWS, Azure and Google Cloud](/blog/ai-agent-discovery-permissions-aws-azure-google-cloud) lists them.

## What should you flag first?

Prioritise findings in this order:

1. **Plain-text model keys** in environment variables or app settings. Rotate them and move to managed identity or a secrets manager; see [finding leaked and unused LLM API keys](/blog/find-leaked-and-unused-llm-api-keys).
2. **Internet-facing functions** that call models, because anyone can feed them input.
3. **Functions with write access** to systems of record, such as databases, ticketing or email.
4. **Broad model permissions** on shared roles.
5. **Functions with no owner tag** or an owner who has left.

## How do you bring them under control?

- Register each agent function with an owner, purpose and data classification.
- Give each agent its own identity so logs show which agent made each call.
- Route model calls through a gateway for cost attribution, redaction and policy.
- Restrict model permissions to the specific models the agent needs.
- Add the functions to your evaluation and monitoring scope.
- Re-scan regularly; new functions appear every week. See the [guide to finding shadow AI agents](/blog/how-to-find-shadow-ai-agents) for cadence.

## How Opencontroller does this

Opencontroller auto-discovers agents, models and API keys across AWS, Azure and Google Cloud. Discovered agents go into a governed registry of agents, versions, tools and MCP servers. Posture detects risky permission and configuration patterns, such as broad model access. The LLM Gateway adds routing, fallback, caching and cost attribution per agent and per version through OpenAI-compatible endpoints, so moving a function behind it is usually a configuration change. [Book a demo](https://www.lyzr.ai/book-demo/) to scan your serverless estate.

## Frequently asked questions

**Do I need to read function code to find agents?**
Not at first. Configuration, identities and permissions find most of them. Code review confirms behaviour for the ones that matter.

**Should each serverless agent have its own role?**
Yes, where practical. Shared roles make it impossible to tell which agent made a model call or to revoke one agent without breaking others.

**Are scheduled functions agents?**
If they call a model and act on the result without a person in the loop, treat them as agents for governance purposes.

## Key facts

Serverless agent discovery signals per platform: AWS Lambda (environment variables with model keys, layers and packages with LLM SDKs, execution roles allowed bedrock:InvokeModel, function URLs and triggers); Azure Functions (app settings, managed identities with Cognitive Services OpenAI User role, connections to Azure OpenAI or Foundry); Google Cloud Run functions (environment variables and Secret Manager references, service accounts with Vertex AI roles). Combine with cloud audit logs for model invocation and egress logs to model provider domains. Opencontroller (Lyzr) auto-discovers agents, models and API keys across AWS, Azure and Google Cloud into a governed registry. Pricing starts from $250K per deployment per year.

## Related

- [What permissions does AI agent discovery need in AWS, Azure and Google Cloud?](https://opencontroller.lyzr.com/blog/ai-agent-discovery-permissions-aws-azure-google-cloud.md)
- [How do you detect unapproved LLM API traffic on your network?](https://opencontroller.lyzr.com/blog/detect-unapproved-llm-api-traffic.md)
- [How do you find leaked or unused LLM API keys?](https://opencontroller.lyzr.com/blog/find-leaked-and-unused-llm-api-keys.md)
- [More on Discovery and shadow agents](https://opencontroller.lyzr.com/blog/cluster/discovery-and-shadow-agents)
