Common Mistakes When Deploying Apps to AWS: 11 Errors That Cost Teams Money and Uptime

Most problems on Amazon Web Services (AWS) aren’t exotic bugs. The usual AWS deployment mistakes are defaults nobody revisited. Think of a user with full admin rights, a firewall rule open to the internet, an idle network gateway or a stack edited by hand. Each one works on day one, which is exactly why it survives until the bill or the outage arrives.

This guide covers 11 errors that cost teams money and uptime. For each one you get the symptom, the cause and the fix, with console paths or AWS Command Line Interface (CLI) commands you can paste. The order follows the damage: security first, then cost, then reliability and process.

How an AWS deployment actually works

Knowing the chain makes most failures easier to place. Your code lands in a repository, and a pipeline builds it into an artifact. That artifact can be a zip file, a container image or a function package for AWS Lambda, the service that runs code without servers you manage. A deployment tool then creates or updates the resources that run it.

On AWS that tool is usually CloudFormation, which turns a template into a “stack” of resources. Terraform does the same job across several clouds. Once the resources exist, traffic only reaches the new version after a health check passes. A load balancer, for example, calls a URL on each server and sends users only to servers that answer correctly.

Every mistake below breaks one link of that chain: who may change resources, what’s exposed, what it costs, and how you recover when the last step fails.

cloud server deployment

1. One admin identity for everything

Symptom: your app, your pipeline and three developers all use IAM (Identity and Access Management) users with the AdministratorAccess policy. IAM is the AWS service that decides who can call which action on which resource. Nothing breaks, so nobody notices.

Cause: a deployment fails with “access denied”, and the fastest way to make the error disappear is to grant everything. Then the shortcut stays. A leaked key from that identity can delete every resource in the account.

Fix: apply the principle of least privilege, which means IAM policies that grant only the actions a workload needs on the resources it touches. When a tool such as Amplify or the AWS Cloud Development Kit (CDK) asks for more permissions, read the error to find the missing action instead of granting full admin. In practice:

  • give workloads IAM roles, not users. Use an instance profile for EC2 (Elastic Compute Cloud, AWS’s virtual servers), a task role for ECS (Elastic Container Service) containers and an execution role for Lambda;
  • let your CI/CD pipeline (continuous integration and delivery) assume a role through OpenID Connect (OIDC) instead of storing access keys; with GitHub Actions, the aws-actions/configure-aws-credentials action takes a role-to-assume parameter;
  • turn on IAM Access Analyzer (IAM console, then Access analyzer) to flag resources shared outside your account and, with its unused-access analyzer, permissions nobody uses;
  • protect the root user with multi-factor authentication (MFA) and don’t create access keys for it, as the AWS IAM best practices recommend.

2. Secrets in code and long-lived access keys

Symptom: a database password sits in a .env file, a Dockerfile or a Lambda environment variable. Anyone with read access to the repository or to that function in the console can see it.

Cause: it’s the quickest way to make a connection string work. Once the secret is copied into several places, you can’t rotate it without redeploying everything.

Fix: store secrets in AWS Secrets Manager, which can rotate database credentials automatically, or as a SecureString in Systems Manager Parameter Store for simpler values. Your code reads them at runtime through its role, so no key lives in the image. Add a secret scanner such as GitHub secret scanning or truffleHog to the pipeline. A key pushed once to a public repository must be treated as stolen: deactivate it, then rotate it.

3. Security groups open to 0.0.0.0/0

Symptom: on an EC2 instance, port 22 for SSH (Secure Shell, the remote login protocol) accepts connections from 0.0.0.0/0, and so does the database port. That range means any IPv4 address on the internet. A security group is the virtual firewall attached to an instance or a database.

Cause: a test instance gets a quick “allow all” rule, then goes to production unchanged. Scanners probe these ports constantly, so an open SSH port that accepts passwords invites brute-force attempts within hours.

Fix: list the offending groups, then remove the rule.

aws ec2 describe-security-groups \
  --filters Name=ip-permission.cidr,Values=0.0.0.0/0 \
  --query "SecurityGroups[*].[GroupId,GroupName]"

aws ec2 revoke-security-group-ingress --group-id sg-0123456789abcdef0 \
  --protocol tcp --port 22 --cidr 0.0.0.0/0

Better still, close port 22 entirely and connect through Session Manager, part of AWS Systems Manager (SSM): aws ssm start-session --target i-0123456789abcdef0. It needs the SSM agent and an instance role, but no inbound rule at all. Only the load balancer should face the internet, on ports 80 and 443. Your app servers and database then accept traffic from the load balancer’s security group, not from an address range.

One trap goes the other way. If you tighten rules while connected through SSH, you can lock yourself out of a running server, so get Session Manager working before you remove the last SSH rule. Also confirm that health checks still reach the instance, because a rule that blocks the load balancer marks every target unhealthy.

cloud server deployment

4. Public or unversioned S3 buckets

Symptom: a bucket in Amazon S3 (Simple Storage Service, AWS’s file storage) was opened for a demo, a contractor or a quick transfer, and it still is. Or a deployment script overwrote a file and the previous version is gone.

Cause: a bucket policy with "Principal": "*" grants access to anyone, even when your IAM users are locked down. AWS has turned on Block Public Access by default for new buckets since April 2023, but older or inherited buckets can predate that change.

Fix: enforce Block Public Access and turn on versioning.

aws s3api put-public-access-block --bucket my-bucket \
  --public-access-block-configuration \
  BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true

aws s3api put-bucket-versioning --bucket my-bucket \
  --versioning-configuration Status=Enabled

Serve public assets through CloudFront, the AWS content delivery network (CDN), with origin access control instead of a public bucket. Then add a lifecycle rule that expires old versions after a set number of days, otherwise versioning quietly grows your storage bill.

5. Oversized instances, or one instance type for everything

Symptom: the bill grows faster than traffic, while CloudWatch, the AWS monitoring service, shows processor usage idling in single digits.

Cause: teams size servers “to be safe” during setup and never revisit the choice. Others pick one type, say a burstable t3.medium, for every workload. Some apps then choke under load while others pay for capacity they never use. aws.com published something useful on the subject.

Fix: start one size below your instinct, measure, and resize. AWS Compute Optimizer analyzes the last 14 days of CloudWatch metrics by default and recommends instance types. Match the instance family to the job:

  • t types for burstable dev servers and low-traffic apps;
  • c types for compute-heavy work such as encoding or builds;
  • r types for memory-heavy work such as caches and large databases;
  • Graviton types such as t4g or m7g, which run on Arm processors and often cost less for the same work if your stack supports Arm.

Some engineers disagree with starting small, and they have a point: an app that stalls on launch day costs trust. The answer is to make resizing cheap. When the instance type is one line in a template, upsizing takes minutes. For steady workloads that run around the clock, Savings Plans or Reserved Instances then lower the price of that baseline.

6. Forgotten resources: idle gateways, environments and volumes

Symptom: a dev account that nobody touches still costs real money every month.

Cause: a NAT Gateway (network address translation, the component that lets private servers reach the internet) bills per hour and per gigabyte processed, even with little traffic. Unattached EBS volumes (Elastic Block Store, the disks behind EC2), old snapshots, idle load balancers and demo instances left running after an event add to the waste.

Fix: hunt them down with the CLI.

aws ec2 describe-nat-gateways --query "NatGateways[*].[NatGatewayId,State,VpcId]"
aws ec2 describe-volumes --filters Name=status,Values=available
aws ec2 describe-addresses --query "Addresses[?AssociationId==null]"

For S3 and DynamoDB traffic from private subnets, a gateway VPC (virtual private cloud) endpoint avoids the NAT Gateway, and AWS doesn’t charge extra for gateway endpoints. In dev accounts, stop instances at night with a scheduled job or the AWS Instance Scheduler solution.

Check CloudWatch Logs too. A new log group keeps its data forever unless you set a retention period, for example with aws logs put-retention-policy --log-group-name /aws/lambda/my-fn --retention-in-days 30.

cloud server deployment

7. No budget alerts

Symptom: you learn about a runaway cost from the invoice, weeks after it started.

Cause: nobody owns cost, and nothing alerts. A classic runaway is a Lambda function triggered by uploads to a bucket that writes its output back to the same bucket, so each write triggers another run. The AWS documentation for S3 triggers warns against this loop and recommends separate buckets or prefixes.

Fix: in the Billing and Cost Management console, open Budgets, then Create budget. Set a monthly cost budget with alerts at, for example, 50%, 80% and 100% of the amount, plus a forecast alert. Turn on Cost Anomaly Detection as well: in our view, a monitor that looks for unusual spending patterns is a useful second net next to fixed budget thresholds.

Then tag every resource with project and environment, and activate those keys as cost allocation tags so Cost Explorer can group spending by them. For a studio running several client apps, that tag turns one opaque bill into a cost per client.

8. One Availability Zone and a fixed number of servers

Symptom: traffic spikes slow the app to a crawl, or a single data center problem takes everything down.

Cause: the app runs on a fixed set of instances in one Availability Zone (AZ), one of the isolated groups of data centers inside a region. Teams skip a second zone early to save money, then forget it once the app becomes critical.

Fix: put instances in an Auto Scaling group spread over at least two zones, behind an Application Load Balancer (ALB). A target tracking policy, for example average processor usage at 50%, then adds and removes instances for you. For Amazon RDS (Relational Database Service), enable Multi-AZ on production databases so a standby takes over during a failure.

Not every app needs this on day one. A client’s brochure site can live with one zone for a while, but a checkout or a booking flow can’t.

9. No backups, no deletion protection

Symptom: an instance dies and takes its local files with it. Or someone deletes a database while “cleaning up test resources” with production credentials loaded in the wrong terminal.

Cause: the belief that AWS handles backups for you. Under the AWS shared responsibility model, AWS secures the infrastructure, and you protect your data and configuration.

Fix: make data loss a deliberate act, never an accident.

  • Create a plan in AWS Backup that selects EBS volumes, RDS databases and DynamoDB tables by tag.
  • Keep RDS automated backups on, with a retention of up to 35 days, and turn on deletion protection: aws rds modify-db-instance --db-instance-identifier prod-db --deletion-protection --apply-immediately.
  • Keep production in a separate AWS account from dev, staging and test, so a script run with the wrong profile can’t reach it.
  • Test a restore. A backup you’ve never restored is only a hope.
cloud server deployment

10. Deploying without health checks or a rollback path

Symptom: a release sends errors to every user at once, or requests drop during the deployment. With AWS CodeDeploy, the deployment stops on a HEALTH_CONSTRAINTS error.

Cause: the new version goes to every server at once, with no gate. The health check either tests nothing useful or tests too much. An endpoint that queries the database can mark healthy servers as dead during a brief spike.

Fix: choose a deployment strategy and let health checks gate it.

  • Rolling replaces servers in batches: cheap, and fine for low-risk apps.
  • Blue/green builds a full second environment and switches traffic in one step, with instant rollback.
  • Canary sends a small share of traffic to the new version first, then expands if error rates stay flat.

Keep the load balancer’s health check light: a /health route that only confirms the process answers. ALB target groups default to a 30-second interval, a 5-second timeout and 2 failed checks before a target counts as unhealthy, which suits most web apps. The deregistration delay, 300 seconds by default, lets in-flight requests finish before an old server leaves.

Finally, attach CloudWatch alarms to the CodeDeploy deployment group and enable rollback when an alarm fires. A spike in 5xx errors then undoes the release without anyone waking up.

11. Changing production by hand

Symptom: terraform plan shows dozens of unexpected changes, or a CloudFormation update fails on a resource that no longer exists.

Cause: “quick fixes” made manually in the AWS console, like a security group rule here and a resized instance there. Over a few months the code stops describing reality, which is called drift. Deleting a stack-managed resource by hand is the worst variant. The next deploy of that stack fails, including with AWS SAM (Serverless Application Model), because CloudFormation still expects the resource.

Fix: define infrastructure as code (IaC) with CloudFormation, the CDK, which lets you write it in TypeScript or Python, or Terraform. Then route every change through a pull request, and let automation in your pipeline apply it. Check for drift on a schedule:

aws cloudformation detect-stack-drift --stack-name myapp
aws cloudformation describe-stack-resource-drifts --stack-name myapp

With Terraform, run terraform plan in your pipeline each week and alert on any difference, then terraform import what was created by hand. Make production read-only in the console for most people. When an incident still points to a manual change, AWS CloudTrail, whose event history logs management API calls such as console changes, shows who made it and when.

A common objection is that IaC is overkill for a two-person team. We disagree: the day one person makes a change and goes on holiday, the template is the only record of what exists.

When the deployment itself fails: reading the error

A failed deployment rarely explains itself on the summary screen. The real cause sits one level down, and each tool hides it in a different place.

CloudFormation. Open the stack’s Events tab, or query the failures directly. In practice, we’d start with the earliest failed event, since later failures often follow from it during the rollback.

aws cloudformation describe-stack-events --stack-name myapp \
  --query "StackEvents[?contains(ResourceStatus,'FAILED')].[LogicalResourceId,ResourceStatusReason]"

Run aws cloudformation validate-template --template-body file://template.yaml before each deploy. This validation catches syntax errors in the YAML, the indented text format most templates use, and some structural ones. A template that validates can still fail when a resource gets an invalid property.

Two stack states confuse people. A stack whose first creation failed ends in ROLLBACK_COMPLETE, and it can only be deleted, then recreated. A stack stuck in UPDATE_ROLLBACK_FAILED needs aws cloudformation continue-update-rollback, often after you fix or skip the resource that blocked it.

CodeDeploy on EC2. A HEALTH_CONSTRAINTS error only means too many instances failed for the deployment to continue. Open the events of a failed instance to see which lifecycle hook broke. Then check three usual suspects on the server:

  • the agent is running: sudo service codedeploy-agent status;
  • appspec.yml sits at the root of the bundle you uploaded;
  • hook scripts use absolute paths, not relative ones.

The agent writes its log to /var/log/aws/codedeploy-agent/codedeploy-agent.log, which usually names the failing script.

The stack succeeded, but the app returns 502 or 503. Targets are unhealthy because the app never started. Connect to the instance and run curl http://localhost: if nothing answers, the startup script failed.

A frequent cause is user data written for one AMI (Amazon Machine Image, the server template) and run on another, such as yum commands on an Ubuntu image.

cloud server deployment

Which AWS deployment mistakes to fix first

The security fixes are cheap and fast, so they come first almost everywhere. After that, the order depends on what you run.

Your situation Fix first Can wait Avoid
Solo developer or small studio, one app Roles instead of admin users, MFA on root, close open ports, one budget alert Multi-AZ, Savings Plans A Kubernetes cluster for a low-traffic app
Agency hosting several client apps Separate accounts per client or environment, cost tags, reusable IaC templates Detailed tracing per client One shared admin user across clients
Growing product with paying users Multi-AZ database, health-gated deploys with rollback, alarms, tested restores Multi-region failover Manual console changes in production
Migration from your own servers Right-sizing, backups and account structure before the move Rewriting everything as Lambda functions Copying each old server one-to-one and keeping its size forever

For the migration case, a lift-and-shift onto EC2 is a fair first step. Fargate, which runs ECS containers without servers to manage, is often the next one. Rewriting a whole app around Lambda rarely pays off as a first move. The opposite mistake exists too: building for millions of users before the first hundred adds complexity you pay for every day.

Once the urgent fixes are done, review the rest against the AWS Well-Architected Framework. Its six pillars are operational excellence, security, reliability, performance efficiency, cost optimization and sustainability, and the free Well-Architected Tool in the console walks you through the questions for each workload.

How to measure whether it’s working

Fixing the mistakes once isn’t enough, because new resources appear every week. Track a few numbers on a fixed rhythm.

  • Security, monthly: open findings in IAM Access Analyzer, and the count of security groups open to 0.0.0.0/0 on admin ports, which should be zero.
  • Cost, weekly: Cost Explorer grouped by your project tag, plus any Compute Optimizer recommendation not yet applied.
  • Reliability, after each release: 5xx rate and latency on the load balancer in CloudWatch, compared with the hour before.
  • Delivery, quarterly: the four DORA (DevOps Research and Assessment) metrics, namely deployment frequency, lead time for changes, change failure rate and time to restore service.

Change failure rate is the one to watch here. When health-gated deploys and IaC are in place, fewer releases should need a rollback or a hotfix. There’s a good explainer over at github.com.

Pre-deployment checklist

  1. No app or pipeline uses an IAM user with AdministratorAccess.
  2. No secret in code, images or plain environment variables.
  3. No security group open to 0.0.0.0/0, except ports 80 and 443 on the load balancer.
  4. Block Public Access on, and versioning on for buckets that matter.
  5. Instance types checked against Compute Optimizer.
  6. No idle NAT Gateway, unattached volume or unused Elastic IP; log retention set.
  7. Budget and anomaly alerts active, every resource tagged.
  8. Production spread over two zones where downtime costs money.
  9. Backup plan active, deletion protection on, restore tested.
  10. Light health check route, rollback alarm attached.
  11. All infrastructure in code, drift check scheduled.

FAQ

Is AWS too expensive for a small app?

It can be. For a static site or a small WordPress blog, a simple virtual server from a smaller host often costs less and needs less setup. AWS pays off when you use its managed services, such as databases, queues and storage, that you’d otherwise have to run yourself. Lightsail and Amplify Hosting are the simpler AWS options for that small-app case.

Should I deploy on Lambda, Fargate or EC2?

Pick by workload, not by popularity. Lambda suits short, event-driven tasks, and a single invocation can’t run longer than 15 minutes. Fargate fits long-running web apps in containers when you don’t want to manage servers, while EC2 gives full control of the operating system.

What’s the quickest way to check my account for these problems today?

Open AWS Trusted Advisor. Its core checks, available on every account, flag security groups with unrestricted ports, a root user without MFA and S3 bucket permissions. Then run the CLI commands from this guide for NAT Gateways, unattached volumes and unused addresses.

I got a huge AWS bill by mistake. Can I get it refunded?

First stop or delete the resource that caused it, so the charge stops growing. Then contact AWS Support about the charge and explain what happened and what you changed. In our opinion it’s worth asking, but don’t plan your budget around getting money back.

Does sticking to AWS-native tools lock me in?

Partly, yes. CloudFormation, ECS and CodePipeline only work on AWS, so moving away later means rewriting templates and pipelines. For a small team on one cloud, the simpler operations usually outweigh that risk; if a multi-cloud move is likely, Terraform and containers keep more doors open.

If you only have an hour this week, spend it on the three cheapest fixes. Replace admin users with roles, close every port open to the world, and set a budget alert. Those remove the mistakes that hurt fastest. Put backups, health-gated deploys and IaC into your next sprint, then run the checklist above before each major release.

Building or moving a web or mobile app to AWS? Keep this checklist next to your release notes, and browse our other development guides on coding4.net before your next deployment.

Leave a Comment

Your email address will not be published. Required fields are marked *