Skip to content

Deploying to AWS

  • AWS account with credentials configured (aws configure or environment variables)
  • cordless.toml in your project root
  1. Creates an IAM role with Lambda basic execution permissions
  2. Packages your source into a zip, bundling any extra packages you specify
  3. Publishes cordless as a Lambda layer (reused across deploys if unchanged)
  4. Creates or updates your Lambda function
  5. Creates an API Gateway HTTP endpoint pointing to the function
  6. If defer_worker is set, deploys a second worker Lambda and wires invoke permissions
[deploy]
function = "my-bot" # Lambda function name
handler = "lambda_function.handler"
region = "eu-west-2"
runtime = "python3.12"
timeout = 10 # seconds (main Lambda)
packages = ["pillow"] # extra pip packages to bundle
# Deferred interactions
defer_worker = "my-bot-worker"
defer_timeout = 30
defer_memory = 256 # MB
[deploy.env]
DISCORD_PUBLIC_KEY = "..."
DISCORD_CLIENT_ID = "..."

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.