The Complete Production SOP: How to Deploy and Run AWS Lambda Container Image Packaging & Provisioned Concurrency in Autonomous AI Agents
Production SOP to package 10GB Docker images and configure Provisioned Concurrency for AWS Lambda using Codex, Claude Code, Cursor, and Windsurf AI agents.
Technical Overview & Architectural Context
Autonomous coding agents frequently stumble when packaging serverless workloads as OCI/Docker container images for AWS Lambda. LLMs typically generate generic Dockerfiles with arbitrary Linux entrypoints, forgetting that AWS Lambda requires either official AWS Lambda base images containing the Runtime Interface Client (RIC) or an explicitly bundled Runtime Interface Emulator (RIE) for local invocation. Furthermore, models often confuse CMD and ENTRYPOINT directives, causing fatal runtime crashes upon execution in the Lambda microVM sandbox. Without strict procedural guardrails, agents also neglect the lifecycle requirements of Provisioned Concurrency. Agents frequently attempt to attach Provisioned Concurrency directly to the mutable `$LATEST` version—an operation explicitly rejected by AWS IAM and the Lambda control plane. This skill enforces deterministic execution rules: standardizing multi-stage builds on `public.ecr.aws/lambda/python:3.12` or `nodejs:20`, declaring handler targets strictly via the `CMD` vector, and mandating that provisioned concurrency targets immutable published versions or qualified aliases (such as `live` or `prod`).
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the skill manifest into your agent runtime's global or workspace-level skill registry.
Autonomous runtimes such as Claude Code and Cursor look for skill manifests in `.claude/skills/` or `~/.agents/skills/`. Placing the verified `aws-lambda-container-image` SKILL.md into this path exposes frontmatter triggers (`build lambda container image`, `eliminate lambda cold start`, `configure provisioned concurrency`) so the agent automatically switches to containerized serverless protocols when prompted.
mkdir -p ~/.agents/skills/aws-lambda-container-image && curl -fsSL https://askills.dev/api/skills/aws-lambda-container-image/raw -o ~/.agents/skills/aws-lambda-container-image/SKILL.md---
name: "aws-lambda-container-image"
description: "Package large Lambda functions (up to 10GB) as Docker containers with provisioned concurrency."
metadata:
author: "AWS"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "build lambda container image"
- "eliminate lambda cold start"
- "configure provisioned concurrency"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Place the SKILL.md in the project-level `.cursor/rules/` or `.claude/skills/` directory to prevent context pollution in unrelated non-AWS repositories.
Ensure permissions retain `shell_exec: false` in untrusted agent environments; allow the agent to emit Dockerfiles and Terraform/SAM templates rather than granting unchecked shell Docker daemon execution.
Container Image Architecture & Dockerfile Synthesis
Direct the agent to generate standard Lambda-compliant multi-stage Dockerfiles.
Instruct the agent to utilize AWS-managed base images. These images automatically bundle the runtime bootstrap and RIC, ensuring the microVM can invoke your handler without requiring custom entrypoint scripts or root execution privileges.
docker build -t my-lambda-service:v1 -f Dockerfile .FROM public.ecr.aws/lambda/python:3.12 AS builder
COPY requirements.txt ${LAMBDA_TASK_ROOT}/
RUN pip install --no-cache-dir -r ${LAMBDA_TASK_ROOT}/requirements.txt --target "${LAMBDA_TASK_ROOT}"
FROM public.ecr.aws/lambda/python:3.12
COPY --from=builder ${LAMBDA_TASK_ROOT} ${LAMBDA_TASK_ROOT}
COPY app.py ${LAMBDA_TASK_ROOT}/
# AWS Lambda base image requires CMD pointing to file.handler_function
CMD [ "app.handler" ]Optimize image layers by copying `requirements.txt` independently of source code to maximize Docker layer caching across agent revisions.
Do not override `ENTRYPOINT` when using AWS provided base images; setting a custom entrypoint bypasses `/lambda-entrypoint.sh` and breaks handler invocation.
Infrastructure Configuration for Provisioned Concurrency
Generate Infrastructure as Code (IaC) that binds Provisioned Concurrency to an immutable alias.
Provisioned Concurrency initializes execution environments beforehand to eliminate cold starts. AWS prohibits setting provisioned concurrency on `$LATEST`. The agent must orchestrate publishing an immutable version and binding an alias.
aws lambda publish-version --function-name MyContainerFunctionresource "aws_lambda_function" "container_app" {
function_name = "ml-inference-service"
package_type = "Image"
image_uri = "123456789012.dkr.ecr.us-east-1.amazonaws.com/ml-service:v1.0.0"
memory_size = 4096
timeout = 30
publish = true
}
resource "aws_lambda_alias" "live" {
name = "live"
description = "Production alias with provisioned capacity"
function_name = aws_lambda_function.container_app.function_name
function_version = aws_lambda_function.container_app.version
}
resource "aws_lambda_provisioned_concurrency_config" "concurrency" {
function_name = aws_lambda_alias.live.function_name
qualifier = aws_lambda_alias.live.name
provisioned_concurrent_executions = 5
}Set memory to at least 1769 MB if processing computational models; AWS Lambda grants a full equivalent vCPU at this threshold.
Provisioned concurrency incurs continuous hourly costs even when idle. Instruct your agent to configure AWS Application Auto Scaling if traffic fluctuates.
Verification, Linting & Output Quality Gate
Run local verification checks using the Lambda Runtime Interface Emulator (RIE).
Before shipping code, verify the container locally by spinning up the emulator on port 8080 and dispatching a simulated API Gateway event.
docker run -d -p 9000:8080 my-lambda-service:v1 && curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"key":"test-payload"}'#!/usr/bin/env bash
set -euo pipefail
CONTAINER_ID=$(docker run -d -p 9000:8080 my-lambda-service:v1)
trap 'docker rm -f $CONTAINER_ID >/dev/null' EXIT
sleep 2
RESPONSE=$(curl -sf -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"records": []}')
if [[ "$RESPONSE" == *"statusCode"* ]]; then
echo "Local Lambda verification passed."
exit 0
else
echo "Unexpected response: $RESPONSE"
exit 1
fiRun verification scripts inside CI pipelines before allowing the agent to submit pull requests targeting production branches.
Ensure that port mappings target host port 9000 or any open port to avoid colliding with local web servers running on standard 8080.
Real-World Scenario: Package a PyTorch Image Model as a 4GB Lambda Container with Zero Cold Start
“Build a Lambda container image for our PyTorch inference app. The payload size exceeds 250MB so package it as a Docker image. Eliminate Lambda cold start using provisioned concurrency of 3 instances on a production alias.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent attempted to attach Provisioned Concurrency directly to the default mutable $LATEST identifier rather than a published numerical version or alias.
aws lambda publish-version --function-name my-func && aws lambda put-provisioned-concurrency-config --function-name my-func --qualifier 1 --provisioned-concurrent-executions 3Root Cause: The Dockerfile defined ENTRYPOINT ["app.handler"] or CMD ["python", "app.py"] which conflicts with the Lambda Runtime Interface Client expectations.
# Replace any custom ENTRYPOINT with CMD referencing module.function_name
CMD [ "app.handler" ]Frequently Asked Questions (AWS Lambda Container Image Packaging & Provisioned Concurrency SOP)
Q:Can I use AWS Lambda Container Image Packaging & Provisioned Concurrency across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification supported across all modern agent runtimes by mounting into the respective tool configuration folder.
Q:How does AWS Lambda Container Image Packaging & Provisioned Concurrency prevent context window overflow during long agent sessions?
By establishing concise procedural boundaries and deterministic validation gates rather than polluting system prompts with redundant rules.
Q:Does this skill require escalated root or container permissions?
No. It is audited with a security score of 98/100 and runs safely within workspace-scoped sandboxes.
Ready to equip your autonomous agent with AWS Lambda Container Image Packaging & Provisioned Concurrency?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.