AWS Global Infrastructure fundamentals
1. Concept
AWS divides its infrastructure into Regions, each containing multiple Availability Zones, so you can choose where applications run.
2. Purpose
Understand where AWS places resources to choose the right deployment location, reduce latency, and avoid service outages when problems occur.
3. How it works
Region and Availability Zone
- Region: A geographic area containing AWS infrastructure, such as Singapore.
- Availability Zone (AZ): One or more data centers with independent power and connectivity; each Region has multiple AZs.
- AZ connectivity: AZs in a Region are connected with low-latency networks.
- Resource scope: EC2, EBS, and subnets belong to one AZ; other services may have Regional or global scope.
Multi-AZ and Multi-Region
- Multi-AZ: Runs an application across AZs in one Region. Another AZ can keep serving after a failure if enough resources and protected data remain.
- Multi-Region: Runs across Regions to serve geographically distributed users or recover from a whole-Region failure.
- Example: Two AZs in Singapore protect against one AZ failing; add another Region for recovery from a Singapore-wide incident.
- Trade-off: Multiple Regions cost more and require an appropriate data replication strategy.
User → Load Balancer
├─ EC2 is in AZ A
└─ EC2 in AZ BSelect Region
- Consider the user's location, what country the data request must be in, whether the service needed is available and the cost.
- Edge location is used to bring content/services closer to users; not an AZ to place EC2 yourself.
- AZ names like ap-southeast-1a may map differently between accounts.
- When you need to compare the same physical location between accounts, use AZ ID.
4. Practical example
A store runs in Singapore across two AZs to withstand an AZ failure.
The website needs to tolerate one data center: ALB and EC2/ASG across at least two AZs, the database has Multi-AZ. Global application needs to recover when Region fails: add DR architecture in another Region.
5. Comparison
A Region is a geographic area; an AZ is a fault domain within it; an Edge Location brings content closer to users.
IAM identities: Root, Users & Groups
1. Concept
IAM controls who can access AWS and what each identity can do with its resources.
2. Purpose
Determine who is using AWS and manage the rights of each person in the account.
3. How it works
AWS account and root user
| Concept | Nature & Scope |
|---|---|
| AWS Account | The isolation unit contains resources and billing on AWS |
| Root User | The account's special identity has very broad permissions, only used for tasks that require root privileges |
- Turn on MFA for root, protect recovery information, do not create root access keys and do not use root for daily work.
- Do not treat the root user as a way to bypass all protection mechanisms: SCP and some mechanisms such as S3 Object Lock Compliance can still limit operations.
IAM Users and Groups
| IAM Identity | Features & Rules |
|---|---|
| IAM User | Long-term identity; can have password (to Console) and/or access key (API/CLI call — two separate credential types) |
| IAM Group | Group IAM Users to grant common permissions; A user can belong to many groups, but the group cannot nest another group and does not contain an IAM Role |
Group Developers → policy allows viewing EC2
├─ User An
└─ User BinhLogin for employees
- Prioritize IAM Identity Center or federation: employees log in and receive access to roles with temporary credentials.
- No need to create and share long-term access keys for each person.
- If using IAM User, log in with account ID/alias, user name and password.
- Each session only has permissions for the identity/role in use.
IAM is global in scope
- No need to recreate IAM User in each Region.
- However, the accessed resource may be located in a specific Region and the policy may limit that scope.
4. Practical example
An engineer can only view production resources; the application uses a separate role to read data.
The audit team uses read-only roles; The development team has limited permissions according to the environment. Use groups to manage common rights for existing IAM Users; Use Identity Center to manage employee access across multiple accounts.
5. Comparison
Root controls the account; an IAM User is a long-lived identity; IAM Groups collect permissions for users, not roles.
IAM policies, Roles & permission model
1. Concept
A policy defines permissions; a role is an identity used to perform work with its assigned permissions.
2. Purpose
Grant the right permissions, on the right resources, without having to share passwords or access keys.
3. How it works
Read a policy
- Policy: JSON rule set.
- Each Statement answers: allow or prohibit, what to do, on what resources and under what conditions.
| Field | Meaning |
|---|---|
| Effect | Allow or Deny |
| Action | API/action, e.g. s3:GetObject |
| Resource | Resource ARN; object ARN is different from bucket ARN |
| Condition | Conditions like MFA, IP or tag |
| Principal | Who is authorized; appears in resource/trust policy, not in identity policy |
- The commonly used version is 2012-10-17; This is the policy language version.
- For example, the identity policy only allows reading objects in a prefix:
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::example-bucket/reports/*"}]}Identity policy and resource policy
- Identity policy attached to user/group/role: what does this identity do?
- A resource policy is attached to a bucket, queue or key and specifies who may access that resource.
- With direct cross-account access, Allow is often needed on both the identity and resource side.
- KMS also has its own key policy; Having S3 permissions may not be able to decrypt the object SSE-KMS.
How to consider rights
- If there is no appropriate Allow, it will be denied by default.
- Explicit Deny wins over Allow.
- Rights are also limited by SCP, permissions boundary or session policy where those mechanisms apply; they are not self-authorizing.
- Least privilege means only granting actions and resources that are truly needed, instead of using * for everything.
Role and STS
- IAM Role: An identity used to perform a task without storing long-lived access keys in the application.
- Trust Policy: Defines who can assume the role.
- Permission Policy: Defines what the role can do and to which resources.
- AWS STS: Issues temporary credentials: an access key, secret key, and session token.
- IAM Roles Anywhere: Lets servers or applications outside AWS obtain temporary role credentials, such as an office server uploading backups to S3. It requires a certificate from a trusted CA and a suitable trust policy.
EC2/Lambda/user → assume role → temporary credential → call AWS APIIAM Roles Anywhere
- IAM Roles Anywhere for the server, container or application to run outside of AWS Use IAM roles to receive temporary credentials, instead of keeping long-term access keys.
Other on-premises / cloud applications + X.509 certificate
↓ authenticate with the registered CA as trust anchor
IAM Roles Anywhere + IAM roles / profiles
↓
Temporary credentials
↓
AWS API according to role permissions- Requires a valid certificate from a trusted CA and an appropriate role trust policy.
- For example, on-premises server uploads backup to S3.
IAM Roles for AWS services
| IAM Role | What to use? |
|---|---|
| EC2 Instance Role | Applications on EC2 call S3, DynamoDB, SQS...; attach the role to EC2 via instance profile |
| ECS Task Role | Applications in ECS containers call AWS APIs |
| ECS Task Execution Role | ECS agent/Fargate pulls image from ECR, sends container logs to CloudWatch Logs |
| Lambda Execution Role | Lambda function calls AWS APIs and records logs according to the policy granted |
| EKS Pod Identity Role | Grant AWS permissions to Pods via association with the Kubernetes Service Account and Pod Identity Agent |
| IRSA Role (EKS) | Pods assume roles via Kubernetes Service Account, IAM OIDC provider and STS |
| Step Functions Execution Role | Workflow calls Lambda, ECS, DynamoDB... according to granted permissions |
| CloudFormation Service Role | CloudFormation creates, edits, and deletes stack AWS resources |
| Cross-Account IAM Role | Principal in another account assumes role to access resources according to trust/permission policies |
| Service-Linked Role | An AWS service manages the necessary resources for you |
EC2 Application
└── EC2 Instance Role → S3
ECS Containers
├── Task Role → App calls S3
└── Task Execution Role → ECS pull ECR / send logs
Lambda Function
└── Lambda Execution Role → DynamoDB
EKS Pod
└── Pod Identity / IRSA Role → S3
Step Functions
└── Execution Role → Lambda
CloudFormation
└── Service Role → Create EC2 / RDS- ECS Task Role grants permissions to applications; Task Execution Role grants permissions to ECS agent/Fargate. Pod Identity and IRSA are two ways to grant AWS permissions to Pods; Details and conditions are in the EKS section. ·
Service-Linked Role
- Service-Linked Role: A role dedicated to an AWS service so it can manage resources for you. AWS defines its permissions and trust.
- Example: Auto Scaling uses it to create or terminate EC2 instances and register them with a load balancer.
- Compared with an Instance Role: An instance role authorizes application code inside EC2, not Auto Scaling operations.
- Creation: Many services create it when needed; the configuring identity needs iam:CreateServiceLinkedRole. Do not edit service-managed permissions.
| AWS service | SLR is used for |
|---|---|
| EC2 Auto Scaling | Manage EC2 lifecycle and register instances with load balancer |
| Elastic Load Balancing | Manage AWS resources needed by the load balancer, such as network interfaces |
| Application Auto Scaling | Scale the resources of supported services, for example ECS service or DynamoDB |
4. Practical example
An image-processing EC2 instance can only read original images and write thumbnails in S3.
EC2 reads an S3 prefix using the instance role; Lambda logs using execution role. Deploy to another account using AssumeRole, with appropriate trust policy and assume rights on both sides.
5. Comparison
A trust policy determines who can assume a role; a permissions policy determines what the role can do.
Inline Policy vs Managed Policy & Identity Aggregation
| Criteria | Inline Policy | Managed Policy |
|---|---|---|
| Nature & Classification | Policy is tied directly to a single identity | Policy exists independently: including AWS Managed (eg AdministratorAccess Omnipotence is different from SystemAdministrator limited administrative rights) and Customer Managed (you create and manage versions yourself) |
| Mounting range | A single User / Group / Role | Reusable for many Users / Groups / Roles |
| Lifecycle when deleting an identity | Delete by ownership identity | Maintain independence within IAM |
| When to use? | 1–1 rights are uniquely tied to an identity | Right to standardize, reuse, and version control |
| Component | Nature | Credential used |
|---|---|---|
| IAM User | Long-term identity in account | Password (Console) or Access Key ID + long-term Secret Access Key |
| IAM Role | The temporary identity is assumed | STS Temporary Credentials (Access Key + Secret Key + Session Token) |
| IAM Policy | JSON document specifies Allow / Deny | Trust Policy (who can assume) · Permission Policy (what can be done) |
IAM credentials, authentication & security tools
1. Concept
The console uses a web interface, the CLI uses commands, and SDKs use code to access AWS; each needs identity authentication.
2. Purpose
Log in and call AWS securely, and find credentials or permissions that are no longer needed.
3. How it works
Two main ways of access:
Console → password + MFA
CLI / SDK → credentials → AWS APIConsole, CLI and SDK
- Console = browser interface; CLI runs command; SDK calls AWS from code.
- CLI/SDK uses temporary credential from SSO/role or long-term access key, IAM User access key is not required.
- Temporary credentials include access key ID, secret access key and session token.
- Do not hard-code credentials into the application; Do not commit the credentials file.
MFA and password policy
- MFA requires additional authentication factors in addition to passwords.
- Prioritize MFA for root and high privileges.
- IAM's password policy controls IAM User password length, complexity, expiration, and reuse; Does not replace MFA and does not apply to all federation systems.
Profile and CloudShell
- CLI profile separates configuration between accounts/roles. aws configure sso set up SSO;
- aws configure can store access keys in ~/.aws/credentials and Region configuration in ~/.aws/config.
- CloudShell: terminal in Console, has CLI available and uses current login session permissions.
- It does not grant itself administrative rights.
Permission checking tool
| Tools | Used to |
|---|---|
| Credentials Report | View IAM User password, access key and MFA status for the entire account |
| Access Advisor | View service usage information to consider narrowing permissions |
| IAM Access Analyzer | IAM Access Analyzer is a service that helps analyze AWS access permissions, detecting permissions that are too broad, permissions that are not in use, or resources that may be accessed unintentionally. |
- Usage data is the basis for review, not the reason for immediate removal: some tasks only run monthly or when DR.
4. Practical example
An employee uses SSO for the CLI instead of storing long-lived access keys on a laptop.
Employees use SSO profiles for CLI; workload uses role. Check access keys that have not been used for a long time, delete excess keys and reduce permissions after checking actual needs.
5. Comparison
MFA strengthens sign-in; Credentials Report checks credentials; Access Analyzer analyzes access permissions.