Deploying to AWS
Prerequisites
Section titled “Prerequisites”- AWS account with credentials configured (
aws configureor environment variables) cordless.tomlin your project root
What cordless deploy does
Section titled “What cordless deploy does”- Creates an IAM role with Lambda basic execution permissions
- Packages your source into a zip, bundling any extra
packagesyou specify - Publishes cordless as a Lambda layer (reused across deploys if unchanged)
- Creates or updates your Lambda function
- Creates an API Gateway HTTP endpoint pointing to the function
- If
defer_workeris set, deploys a second worker Lambda and wires invoke permissions
cordless.toml reference
Section titled “cordless.toml reference”[deploy]function = "my-bot" # Lambda function namehandler = "lambda_function.handler"region = "eu-west-2"runtime = "python3.12"timeout = 10 # seconds (main Lambda)packages = ["pillow"] # extra pip packages to bundle
# Deferred interactionsdefer_worker = "my-bot-worker"defer_timeout = 30defer_memory = 256 # MB
[deploy.env]DISCORD_PUBLIC_KEY = "..."DISCORD_CLIENT_ID = "..."Deferred interactions
Section titled “Deferred interactions”Some commands take longer than Discord’s 3-second limit. Mark them with defer=True:
@cog_command("slowthing", description="Takes a moment", defer=True)async def slowthing(self, ctx): await asyncio.sleep(5) await ctx.send("Done!")cordless responds immediately with a loading state, then invokes the worker Lambda in the background to send the real response.
Set defer_worker in cordless.toml to enable this.
