Cloud & Hosting (AWS)

AWS Setup & Deployment Guide

Start with Amazon Web Services safely – secure the account, set up the AWS CLI, control costs and choose the right services for your app.

Updated Official documentation ↗

1. Introduction & use cases

Amazon Web Services (AWS) is the largest cloud platform, with 200+ services for compute, storage, databases, networking, machine learning and more, available in regions around the world (including Mumbai, ap-south-1, and Hyderabad, ap-south-2, in India). You pay for what you use.

The most important first steps are security (MFA, no daily use of the root user, least-privilege access) and cost control (budgets and alerts). Then pick services: EC2 for servers, S3 for files, RDS for databases, CloudFront for CDN and Lambda for serverless code.

Where it is used

  • Hosting websites, APIs and mobile back-ends
  • Storing files, backups and media at any scale
  • Managed databases, caches and queues
  • Serverless and container platforms (Lambda, ECS, EKS)

2. Prerequisites

You needVersion / notes
Email + phoneFor account sign-up and verification
Payment cardRequired even for free usage (Indian accounts may be billed by AWS India)
Authenticator appFor multi-factor authentication (MFA)
TerminalFor the AWS CLI

3. Local setup

  1. 1Create the account and secure the root user

    Sign up at aws.amazon.com. Immediately enable MFA on the root user (IAM → Security credentials) and do not create root access keys. Use the root user only for account-level tasks.

  2. 2Create an admin identity for daily work

    Recommended: IAM Identity Center → enable → create a user → assign the AdministratorAccess permission set to your account. You will sign in through the AWS access portal URL it shows. (Small/personal setups can use an IAM user with MFA instead.)

  3. 3Install AWS CLI v2

    Windows: run the MSI. macOS: the .pkg installer. Linux:

    BASH
    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o awscliv2.zip
    unzip awscliv2.zip
    sudo ./aws/install
    aws --version
    
    # Windows (PowerShell)
    msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
  4. 4Configure the CLI

    With Identity Center use SSO (short-lived credentials, nothing secret saved on disk).

    BASH
    aws configure sso
    # SSO start URL: https://d-xxxxxxxxxx.awsapps.com/start
    # SSO region: ap-south-1
    # choose account + role, CLI default region: ap-south-1, profile name: dev
    
    aws sso login --profile dev
    aws sts get-caller-identity --profile dev

4. Create & run a project

  1. 1Set a budget alert first

    Billing and Cost Management → Budgets → Create budget → “Monthly cost budget”, e.g. $10, with email alerts at 80% and 100%. Also check the current Free Tier offer for your account (AWS changed the Free Tier for new accounts in 2025).

  2. 2Create your first resource with the CLI

    An S3 bucket (names are globally unique) and a test upload.

    BASH
    export AWS_PROFILE=dev
    aws s3 mb s3://my-first-bucket-$RANDOM --region ap-south-1
    aws s3 ls
    echo "hello aws" > hello.txt
    aws s3 cp hello.txt s3://YOUR_BUCKET/
    aws s3 ls s3://YOUR_BUCKET/
  3. 3Explore regions and services

    Pick one region close to your users for most resources. Some global services (CloudFront certificates, IAM) are special – see their guides.

    BASH
    aws ec2 describe-regions --query "Regions[].RegionName" --output table
  4. 4Clean up

    Delete test resources so they do not cost money.

    BASH
    aws s3 rb s3://YOUR_BUCKET --force

✅ When it works you should see output like Figure 1.

5. Development configuration

Environment variables

The CLI and SDKs read credentials from profiles (~/.aws/config) or environment variables. On AWS compute (EC2, Lambda, ECS) use IAM roles instead of access keys.

.env
AWS_PROFILE=dev
AWS_REGION=ap-south-1
# Avoid long-lived keys; if you must use them:
# AWS_ACCESS_KEY_ID=...
# AWS_SECRET_ACCESS_KEY=...

Key dependencies

Package / toolUsed for
AWS CLI v2Command-line access
AWS SDKsboto3 (Python), @aws-sdk/* (JavaScript v3), AWS SDK for Go/Java/PHP
IAM / Identity CenterUsers, roles and permissions
AWS Budgets / Cost ExplorerCost tracking and alerts
CloudTrailAudit log of API calls
IaC toolsCloudFormation, AWS CDK, Terraform, SAM

Folder structure

project structure
~/.aws/
├── config        # profiles, regions, SSO settings
└── credentials   # only if you use access keys

infra/            # in your repo
├── cdk/ or terraform/
└── README.md

Essential commands

CommandWhat it does
aws configure sso / aws sso loginSet up and refresh SSO credentials
aws sts get-caller-identityWho am I?
aws <service> helpBuilt-in documentation
--profile NAME --region CODEChoose account/region per command
--output table|json|textOutput format
--query "…"Filter output (JMESPath)

6. Production deployment

There is no single “AWS deployment” – choose the service that fits the app. A typical small production setup:

Server & hosting requirements

RequirementRecommendation
Static site / SPAS3 + CloudFront + ACM certificate
API / full app on a serverEC2 (or Lightsail) + Nginx + SSL
DatabaseRDS in private subnets
Serverless functionsLambda + API Gateway / Function URLs
Containers at scaleECS Fargate or EKS (Kubernetes)
DomainRoute 53 or your registrar’s DNS

Deployment steps

  1. 1Separate environments

    Use separate AWS accounts (AWS Organizations) or at least separate stacks/tags for dev, staging and production.

  2. 2Use roles, not keys

    Give EC2/Lambda/ECS an IAM role with only the permissions they need; give CI a role through OIDC (see GitHub Actions).

  3. 3Turn on auditing and alerts

    Enable CloudTrail for the account, keep the budget alerts, and create CloudWatch alarms for key metrics (CPU, errors, 5xx).

  4. 4Describe infrastructure as code

    Keep CloudFormation/CDK/Terraform files in Git so environments are reproducible and reviewed.

    BASH
    # AWS CDK example
    npm install -g aws-cdk
    cdk init app --language typescript
    cdk bootstrap
    cdk deploy
  5. 5Point your domain

    Create a Route 53 hosted zone (or use your registrar’s DNS) and add records to your CloudFront distribution, load balancer or Elastic IP.

🗺 The whole path from your code to the live site is drawn in the deployment diagram.

7. Images & screenshots

Illustrations drawn for this guide from the commands above. Product dashboards change often, so for screens such as cloud consoles follow the step text and the official documentation.

terminal$ aws sts get-caller-identity --profile dev{ "UserId": "AROAEXAMPLEID:asha", "Account": "123456789012", "Arn": "arn:aws:sts::123456789012:assumed-role/AWSReservedSSO_AdministratorAccess…}$ aws s3 mb s3://my-first-bucket-21734 --region ap-south-1make_bucket: my-first-bucket-21734
Figure 1: terminal output of the sample AWS project (section 4).
1Secure account(MFA)2Identity Center +CLI3Budgets +CloudTrail4Pick services(EC2/S3/RDS…)5IaC + domain
Figure 2: production deployment flow (section 6).
~/.aws/├── config # profiles, regions, SSO settings└── credentials # only if you use access keysinfra/ # in your repo├── cdk/ or terraform/└── README.md
Figure 3: project folder structure (section 5).

8. Common errors & solutions

Unable to locate credentials

Run aws sso login --profile NAME (or aws configure), and pass --profile or set AWS_PROFILE.

An error occurred (AccessDenied)

The identity lacks permission for that action/resource. Check its policies (IAM policy simulator helps).

Resources “disappeared”

You are looking at another region in the console or CLI. Switch region (top-right) or pass --region.

Unexpected bill

Check Cost Explorer by service and region; common causes are running instances, NAT gateways, unattached Elastic IPs and snapshots. Set budgets before experimenting.

The security token included in the request is expired

SSO credentials are short-lived – run aws sso login again.

Best practices

  • MFA everywhere; never use the root user for daily work.
  • Least-privilege IAM; roles instead of access keys.
  • Budgets and alerts from day one.
  • One main region near your users (e.g. ap-south-1 for India).
  • Tag resources (project, env, owner) to track costs.