Skip to main content

dpl.configure()

dpl.configure() is called at module level in routes.py to configure the AWS Lambda function that deployless generates for that feature. Every parameter maps directly to a property on the AWS::Serverless::Function resource in the generated template.yaml.

It is a no-op at runtime: when your Flask app starts normally, this call does nothing. Only the deployless compiler reads it.

Full parameter reference​

import deployless as dpl

dpl.configure(
# ── Basic ──
memory=512, # int — MB (128–10240). Overrides globals.memory
timeout=30, # int — Seconds (1–900). Overrides globals.timeout
description="My feature", # str — Description visible in CloudFormation

# ── Environment ──
env={"FLAG": "true"}, # dict — Additional env vars for this Lambda
layers=["arn:aws:lambda:..."],# list — Lambda Layer ARNs

# ── IAM ──
policies=[
"AmazonDynamoDBReadOnlyAccess", # Managed policy by name
{"DynamoDBCrudPolicy": {"TableName": dpl.Ref(my_table)}}, # SAM policy
{"Version": "2012-10-17", "Statement": [...]}, # Inline policy
],

# ── Resources (permission overrides only) ──
# Resources are auto-detected. Use resources= ONLY to override
# the default "crud" permission level:
resources={
"uploads_bucket": (uploads_bucket, "read"),
"jobs_queue": (jobs_queue, "send"),
},

# ── Architecture ──
architectures=["arm64"], # ["x86_64"] or ["arm64"] (Graviton, ~20% cheaper)
tracing=True, # Enables AWS X-Ray distributed tracing

# ── Concurrency ──
reserved_concurrency=10, # int >= 0 — Max simultaneous executions
# 0 = full throttle (useful for temporarily disabling)
provisioned_concurrency=3, # int >= 1 — Pre-warmed instances (eliminates cold starts)
# Implies AutoPublishAlias: live in the template

# ── Temporary storage ──
ephemeral_storage=1024, # int — /tmp size in MB (512–10240, default 512)

# ── Reliability ──
dlq=True, # Creates an SQS Dead Letter Queue for
# failed asynchronous invocations

# ── Observability ──
log_retention=30, # int — Retention days in CloudWatch (overrides global)
)

Example​

app/features/user/routes.py
from flask import Blueprint
import deployless as dpl

# Resource auto-detected → DynamoDBCrudPolicy auto-generated
users_table = dpl.DynamoDB(
"users-table",
pk="tenant_id",
sk="user_id",
gsi=[{"name": "EmailIndex", "pk": "email"}],
ttl_attribute="expires_at",
deletion_policy="Retain",
)

dpl.configure(
memory=512,
timeout=30,
description="User Management API",
architectures=["arm64"],
dlq=True,
log_retention=30,
)

user_bp = Blueprint("user_bp", __name__, url_prefix="/users")

@user_bp.route("", methods=["GET"])
def list_users():
...

dpl.Ref() and dpl.GetAtt()​

Use dpl.Ref(resource) to get the logical ID of a resource (generates {"Ref": "LogicalId"}), and dpl.GetAtt(resource, attr) to get a specific attribute (generates {"Fn::GetAtt": ["LogicalId", "Attr"]}).

They are typically used in policies= for non-standard permissions:

tabla = dpl.DynamoDB("users-table")
bucket = dpl.S3("uploads")

dpl.configure(
resources={"users": tabla, "uploads": bucket},
policies=[
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["dynamodb:Query"],
"Resource": {
"Fn::Sub": "${%s.Arn}/index/EmailIndex" % dpl.Ref(tabla)
},
},
]
}
],
)

Both dpl.Ref() and dpl.GetAtt() accept a resource object or a string with the CloudFormation logical ID.