
Deploy an AWS Lambda MicroVM with the OpenAI Codex CLI, powered by Amazon Bedrock and reachable through an interactive shell.
SHELL_INGRESS network connector, so you connect over an interactive shell and run codex directly inside the isolated Firecracker VM.amazon-bedrock model provider, so inference runs on Amazon Bedrock with credentials supplied at runtime by the MicroVM execution role. There is no ChatGPT sign-in, no OPENAI_API_KEY, and no Amazon Bedrock API key stored in the image. Codex is also wired to the AWS MCP Server from the Agent Toolkit for AWS through the MCP Proxy for AWS, which signs each request with AWS Signature Version 4 (SigV4) using the same execution-role credentials, so it can make live AWS API calls, search AWS documentation, and retrieve AWS skills. Access is read-only, enforced by AWS Identity and Access Management (IAM).src/app.py renders the model, MCP endpoint, and Region into the Codex configuration at runtime from the MicroVM environment, at startup and on every run and resume. The MicroVM suspends when idle, resumes on demand, and has a hard maximum lifetime, so treat it as disposable.git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-microvms-codex-agent/python/cloudformationexport AWS_REGION="us-east-2"./deploy.sh./connect.sh <microvm-id> $AWS_REGIONcodex --version then codex exec "Say hello in one word"codex exec "search the AWS documentation for Lambda MicroVMs idle policy"MICROVM_ID="<microvm-id>" AWS_REGION="$AWS_REGION" ./cleanup.sh