/serverless-compute-skills:aws-lambda-packaging-and-configurationfrom serverless-compute-skills
Packages AWS Lambda functions as zip or container images, tunes memory/timeout/storage, mitigates cold starts, and scopes IAM execution roles to least privilege.
Ships in serverless-compute-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A Lambda function's runtime behavior — how fast it starts, how much it costs per invocation, and what it can access — is determined almost entirely by decisions made at packaging and configuration time, not by application code. Choosing zip vs. container image affects size limits and build tooling; memory affects allocated CPU (not just RAM); and the execution role's IAM policy determines the function's real security blast radius. Getting these wrong doesn't usually fail fast — it shows up later as throttling under load, unexplained latency, or an over-permissioned function nobody scoped down after the initial "just get it working" deploy.
/tmp) size
for a workload that is timing out, running out of disk, or costing more
than expected.python3.9, nodejs16.x reach
end-of-support over time); check aws lambda list-runtimes equivalent
guidance in the AWS docs rather than assuming a version is still
supported.Choose zip vs. container image packaging deliberately, not by default. A zip deployment package is simplest for small, pure-language-runtime functions and deploys faster; it's capped at 50 MB zipped (via direct upload — larger via S3) and 250 MB unzipped including any layers. A container image (via ECR) supports up to 10 GB and is the better fit when you have large dependencies (ML frameworks, native binaries compiled for the target architecture) or want to reuse an existing container build/scan pipeline:
FROM public.ecr.aws/lambda/python:3.12
COPY requirements.txt ${LAMBDA_TASK_ROOT}
RUN pip install -r requirements.txt -t ${LAMBDA_TASK_ROOT}
COPY app.py ${LAMBDA_TASK_ROOT}
CMD ["app.handler"]
docker build -t my-fn:latest .
aws ecr get-login-password --region <REGION> \
| docker login --username AWS --password-stdin <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com
docker tag my-fn:latest <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/my-fn:latest
docker push <AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/my-fn:latest
Create the function with an explicit, least-privilege execution role — never attach a broad managed policy like administrator access "to make it work":
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" }, "Action": "sts:AssumeRole" }
]
}
{
"Version": "2012-10-17",
"Statement": [
{ "Effect": "Allow", "Action": ["logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents"], "Resource": "arn:aws:logs:<REGION>:<AWS_ACCOUNT_ID>:log-group:/aws/lambda/my-fn:*" },
{ "Effect": "Allow", "Action": ["s3:GetObject"], "Resource": "arn:aws:s3:::my-input-bucket/uploads/*" },
{ "Effect": "Allow", "Action": ["dynamodb:PutItem", "dynamodb:GetItem"], "Resource": "arn:aws:dynamodb:<REGION>:<AWS_ACCOUNT_ID>:table/my-fn-state" }
]
}
aws lambda create-function \
--function-name my-fn \
--package-type Zip \
--runtime python3.12 \
--handler app.handler \
--role arn:aws:iam::<AWS_ACCOUNT_ID>:role/my-fn-execution-role \
--zip-file fileb://function.zip \
--memory-size 512 \
--timeout 10 \
--architectures arm64
Tune memory deliberately — memory also determines allocated CPU, not just available RAM. Lambda allocates CPU proportionally to the configured memory (128 MB–10,240 MB, in 1 MB increments); a CPU-bound function that "should have enough RAM" can still be slow simply because it's under-provisioned on CPU. Raising memory is often the correct fix for a slow-but-not-memory-hungry function, and because billing is duration × memory, a higher memory setting can sometimes lower total cost by finishing faster.
Set timeout and ephemeral storage to match the actual workload, not
the default (3 seconds timeout, 512 MB /tmp). Timeout ranges from
1 to 900 seconds (15 minutes); ephemeral storage is configurable up to
10,240 MB:
aws lambda update-function-configuration \
--function-name my-fn \
--timeout 30 \
--ephemeral-storage Size=2048
Mitigate cold starts for latency-sensitive paths, in order of impact: keep the deployment package/image small and dependency-light; initialize SDK clients, DB connections, and other reusable state outside the handler function body so they're reused across invocations within the same execution environment; avoid attaching the function to a VPC unless it genuinely needs to reach a private resource (VPC attachment adds networking setup overhead, though AWS's Hyperplane ENI model has reduced this compared to older one-ENI-per-invocation behavior); and for functions where p99 latency on the first invocation genuinely matters, enable Provisioned Concurrency:
aws lambda put-provisioned-concurrency-config \
--function-name my-fn \
--qualifier prod \
--provisioned-concurrent-executions 5
Provisioned Concurrency must target a published version or alias, not
$LATEST — plan a versioning/alias strategy alongside it.
Use Lambda layers for shared dependencies across multiple functions,
not for every dependency in every function — a layer is a versioned zip
of libraries mounted at /opt, counted against the same 250 MB
unzipped limit as function code:
aws lambda publish-layer-version \
--layer-name shared-utils \
--zip-file fileb://layer.zip \
--compatible-runtimes python3.12
arm64 (Graviton) architecture for new functions where the
runtime and dependencies support it — AWS documents it as generally
offering better price-performance than x86_64; verify any native
binary dependencies are built for the target architecture.prod, staging) as the stable
target for Provisioned Concurrency and downstream integrations, rather
than pointing everything at the mutable $LATEST..dockerignore) — a bloated image slows both cold starts and CI build
times.Symptom: A CPU-bound function intermittently times out or runs slowly even though it never approaches its memory limit. Fix: Increase memory anyway — CPU is allocated proportionally to memory, so a function with plenty of spare RAM can still be CPU-starved; re-test duration at a higher memory setting rather than assuming memory headroom means CPU headroom too.
Symptom: First invocation after an idle period is noticeably slower than steady-state invocations, especially for a VPC-attached function with a large deployment package. Fix: Trim the package/image, move client/connection initialization outside the handler, drop VPC attachment if the function doesn't actually need private-network access, and enable Provisioned Concurrency for the specific alias serving latency-sensitive traffic.
Symptom: The execution role was broadened to
"Action": "*", "Resource": "*" (or a broad managed policy attached)
during troubleshooting "to make it work," and never scoped back down.
Fix: Treat this as a real security finding, not a shortcut — replace
it with the specific actions and resource ARNs the function actually
calls, verified against CloudTrail if it's unclear what the function
uses.
Symptom: aws lambda create-function (or CI upload) fails with a
package-too-large error.
Fix: Zip direct-upload is capped at 50 MB; upload to S3 first and
reference S3Bucket/S3Key, or switch to container image packaging
(10 GB limit) if dependencies are inherently large.
Symptom: The function works locally but fails at runtime with an
import/native-library-load error.
Fix: A native dependency was built for the wrong CPU architecture —
rebuild dependencies (or the container image) for the same architecture
configured on the function (arm64 vs x86_64).
Scenario: An image-processing function (Python, Pillow, with native image-codec bindings) needs to resize uploaded images from S3 and write results to DynamoDB, with low p99 latency for a user-facing upload flow.
Packaging: native Pillow dependencies make a container image the better
fit, built FROM public.ecr.aws/lambda/python:3.12, pushed to ECR as
shown in step 1.
Configuration:
aws lambda create-function \
--function-name image-resizer \
--package-type Image \
--code ImageUri=<AWS_ACCOUNT_ID>.dkr.ecr.<REGION>.amazonaws.com/image-resizer:latest \
--role arn:aws:iam::<AWS_ACCOUNT_ID>:role/image-resizer-execution-role \
--memory-size 1769 \
--timeout 15 \
--ephemeral-storage Size=1024 \
--architectures arm64
1769 MB was chosen deliberately — it's the point at which Lambda
allocates the equivalent of one full vCPU, and testing across a few
memory settings showed it minimized duration × cost for this CPU-bound
resize operation. The execution role (step 2 pattern) is scoped to
s3:GetObject on arn:aws:s3:::uploads-bucket/incoming/* and
dynamodb:PutItem/GetItem on the single results table — not full S3 or
DynamoDB access.
Cold-start mitigation: a prod alias points at the current published
version, with Provisioned Concurrency of 3 on that alias so the
user-facing upload path never pays a cold start during business hours;
a lower-traffic batch alias (used for a nightly reprocessing job) has no
provisioned concurrency, since occasional cold starts there are
acceptable.
Before this configuration ships, run it through aws-lambda-configuration-validation to confirm the reserved/provisioned concurrency numbers don't starve the account's shared concurrency pool and that the environment variables and role policy don't regress.
What SKILL.md sets; muted values are Claude Code's defaults
10 skills in this plugin
/aws-lambda-configuration-validationValidates an AWS Lambda function's configuration — reserved/provisioned concurrency budget, VPC networking config, environment variables, IAM execution role scope, and failure handling — before it deploys, catching problems that only otherwise surface as production throttling or an incident. Use when the user asks to "validate a Lambda function before deploy," "check Lambda reserved concurrency," "review a Lambda IAM role," "why is my Lambda throttling," or "add a pre-deploy check for Lambda config."
/azure-functions-configurationConfigures Azure Functions hosting plans (Consumption, Premium, Dedicated/App Service), triggers and bindings, and host.json/ application settings, with explicit cold-start tradeoffs between plans. Use when the user asks to "choose an Azure Functions hosting plan," "set up a Function App trigger or binding," "reduce Azure Functions cold start," "configure Premium plan pre-warmed instances," or "write host.json for a Function App."
/dapr-configuration-validationValidates Dapr component configurations — state store, pub/sub, and binding components — before deploy, catching missing scopes, inline secrets, unbounded retries, and resiliency gaps that `kubectl apply` won't reject. Use when the user asks to "validate a Dapr component before deploy," "check Dapr component scoping," "review a Dapr pub/sub config for secrets," "add a pre-deploy gate for Dapr components," or "why did my Dapr component apply but not work as expected."
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin serverless-compute-skillsOther plugins' skills for the same job