
10 AWS habits that separate production from tutorial code
OIDC for CI, idempotent handlers, DLQs, JSON logs, symptom alarms and cost tags: ten habits that make AWS workloads hold up in production.
Tutorial code proves a service works. Production code has to keep working at 3 a.m., on retries, and after the person who wrote it has moved teams. These ten habits are where the gap usually is.

Deploy
1. Give CI a role, not access keys
Long-lived access keys in CI secrets are a leak waiting to happen. With OIDC, GitHub Actions swaps a short-lived token for temporary credentials:
permissions: id-token: write contents: readsteps: - uses: aws-actions/configure-aws-credentials@v4 with: role-to-assume: arn:aws:iam::123456789012:role/deploy aws-region: ap-south-1Scope the role's trust policy to your repository and branch.
2. Put everything in infrastructure as code
If it was clicked together in the console, it can't be reviewed, diffed or rebuilt. Use CDK, CloudFormation or Terraform, and treat console access to production as read-only.
3. Separate environments by account
Tags and naming conventions don't stop a dev script from deleting a production table. Separate AWS accounts under AWS Organizations do, and they give you clean cost and permission boundaries too.
Build for failure
4. Make handlers idempotent
SQS standard queues, EventBridge and asynchronous Lambda invokes all deliver at least once. Assume every message can arrive twice. Use an idempotency key with a conditional write; Powertools for AWS Lambda has a ready-made idempotency utility.
5. Set timeouts and retry with backoff
Set explicit connect and read timeouts on every client; defaults are often far longer than your caller will wait. The AWS SDKs already retry with exponential backoff and jitter, so tune
max_attempts instead of writing your own loop, and don't retry inside a retry.6. Give every queue a dead-letter queue
Without a DLQ, one bad message blocks or loops forever. Set a sensible
maxReceiveCount , and put an alarm on the DLQ's message count. For Lambda consumers, set the queue's visibility timeout to at least six times the function timeout.Operate
7. Log JSON, then query it
Structured logs turn CloudWatch Logs Insights into a real debugging tool:
fields @timestamp, @message| filter level = "ERROR"| stats count() by bin(5m)Include a request or correlation ID in every line so you can follow one request across services.
8. Alarm on symptoms
Alarm on what users feel: error rate, p99 latency, and queue age (
ApproximateAgeOfOldestMessage ). CPU alarms alone tell you a machine is busy, not that anything is wrong.9. Tag for cost from day one
Agree on a few tags (
team , service , env ), enforce them in your IaC, and activate them as cost allocation tags in Billing. They only apply from the day you activate them, so do it early.10. Keep secrets in Secrets Manager
No secrets in code, CI variables or plain environment variables. Store them in Secrets Manager or Parameter Store, grant access through the workload's IAM role, and turn on rotation where the service supports it.
Quick checklist
- [ ] CI uses OIDC, no stored keys
- [ ] All infrastructure in code
- [ ] One account per environment
- [ ] Idempotent handlers
- [ ] Explicit timeouts, SDK retries tuned
- [ ] DLQ and alarm on every queue
- [ ] JSON logs with a correlation ID
- [ ] Alarms on errors, latency and queue age
- [ ] Cost allocation tags active
- [ ] Secrets in Secrets Manager
Which of these does your team still skip? And what would you add as number eleven?
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article