This lesson combines 3 topics: Advanced IAM, KMS and Secrets Manager, ACM and CloudFront Security.
Learning Objectives
- Understand Identity Federation (SAML, OIDC, Cognito)
- Master Permission Boundaries and STS
- Apply IAM Access Analyzer
- Understand ABAC (Attribute-Based Access Control)
- Understand KMS: keys, encryption, envelope encryption
- Distinguish CMK types: AWS-managed, Customer-managed, AWS-owned
- Master Secrets Manager vs Parameter Store
- Apply rotation, cross-account sharing
- Understand how AWS Certificate Manager (ACM) issues free SSL/TLS certs
- Master CloudFront fundamentals + caching
- Protect the origin with OAC (Origin Access Control)
- Implement signed URLs / signed cookies
Part 1: Advanced IAM
1. STS (Security Token Service)
Definition
STS = the service that issues temporary security credentials (Access Key + Secret + Session Token).
Use cases
- Assume Role (cross-account access)
- Identity federation (SAML, OIDC)
- Web identity (Cognito)
- MFA-protected operations
Key STS API operations
| API | Use case |
|---|---|
AssumeRole | Assume IAM Role (cross-account, EC2, etc.) |
AssumeRoleWithSAML | SAML-federated (corporate AD) |
AssumeRoleWithWebIdentity | OIDC-federated (Google, Facebook, Cognito) |
GetSessionToken | MFA-protected, temporary credentials |
GetFederationToken | Federate non-AWS users |
GetCallerIdentity | "Whoami" |
Token characteristics
- Lifetime: 15 minutes - 12 hours (default 1 hour)
- Cannot be revoked (until expiry)
- Auto-included AccessKey, SecretKey, SessionToken
2. Cross-Account Access
Pattern: Account A user assumes role in Account B
Setup
- Account B: Create role with trust policy allowing Account A
- Account A: User has permission
sts:AssumeRoleon Account B role ARN - User runs
aws sts assume-role --role-arn arn:aws:iam::B:role/DataReaderRole - Get temp credentials
- Use credentials to access Account B resources
Trust Policy example
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::111111111111:root"
},
"Action": "sts:AssumeRole",
"Condition": {
"Bool": { "aws:MultiFactorAuthPresent": "true" }
}
}]
}
→ Account 111... can assume the role, MFA required.
ExternalID (security best practice)
- When you share a role with a 3rd party (vendor), add an ExternalID to the trust policy
- The vendor must provide the ExternalID when assuming the role
- Protects against the confused deputy problem (the vendor being socially engineered)
3. Identity Federation
SAML 2.0
- Enterprise SSO: corporate AD, Okta, Azure AD
- IdP (Identity Provider) → STS → AWS Console/CLI
Flow
1. User → IdP (log in with corporate creds)
2. IdP returns SAML assertion
3. App calls sts:AssumeRoleWithSAML
4. STS returns temp credentials
5. User accesses AWS
OIDC (OpenID Connect)
- Web identity providers: Google, Facebook, Apple, GitHub
- Mobile apps, web apps
AWS IAM Identity Center (formerly AWS SSO)
- Recommended modern solution
- SSO across AWS accounts + business apps
- Built-in IdP or integrate with AD, Okta, Azure AD
- Permission sets manage role mapping
Benefits
- Centralized user management
- Multi-account SSO with single login
- Replace per-account IAM users
4. Cognito (User Identity)
2 components
User Pool
- User directory (sign-up, sign-in, password reset)
- Built-in or federated (Google, Facebook, SAML)
- JWT tokens for app authentication
Identity Pool (formerly Federated Identities)
- Exchange identity provider token → AWS temp credentials (STS)
- Direct AWS access from mobile/web app
- 2 roles: authenticated, unauthenticated (guest)
Use case
- Mobile app users → S3 upload personal files
- Web app users → DynamoDB access scoped to user
Architecture
Mobile App → User Pool (sign in) → JWT token
→ Identity Pool (exchange token) → AWS temp credentials
→ DynamoDB / S3 / API Gateway
5. Permission Boundaries
Definition
Permission Boundary = MAX permissions an IAM entity can have, regardless of attached policies.
Characteristics
- Apply to IAM User or Role
- NOT a grant — just a ceiling
- Effective permission = Identity policy ∩ Permission boundary
Example
Identity Policy: allow s3:*, ec2:*, iam:*
Permission Boundary: allow s3:*, ec2:* (NO iam:*)
Effective: s3:* and ec2:* (iam:* blocked by boundary)
Use case
- Developers self-service IAM (create new roles for their apps)
- Boundary prevents creating roles with admin permissions
- Delegated administration
SCP vs Permission Boundary
| SCP (Organizations) | Permission Boundary | |
|---|---|---|
| Scope | OU / Account | Individual IAM User/Role |
| Apply to | Member accounts | Identity |
| Grant | No (limit only) | No (limit only) |
| Set by | Master account | Account admin |
SCP is a core topic for SAP-C02. For SAA-C03, understanding the basic concept is enough.
6. AWS Organizations Brief
Definition
Organizations = multi-account management.
Components
- Management Account (Root): billing, organization-wide
- Organizational Unit (OU): group accounts
- Member Accounts: individual accounts
SCP (Service Control Policy)
- Allow list or Deny list of IAM actions across accounts
- Applied at the OU/Account level
- Does not grant permissions — only sets the maximum
SAA-C03 usually asks about SCP basics. The deep details are in SAP-C02.
7. ABAC (Attribute-Based Access Control)
Definition
ABAC = grant permissions based on attributes (tags) instead of specific resource ARNs.
Compared with RBAC (Role-Based)
- RBAC: separate role per resource set ("admin", "developer-app-A", "developer-app-B")
- ABAC: 1 policy, scale automatic with new resources/users
Example policy
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "ec2:*",
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:ResourceTag/Department": "${aws:PrincipalTag/Department}"
}
}
}]
}
→ User can access EC2 instances only if user's Department tag matches resource's Department tag.
Benefits
- Scale (new resources auto-covered by tags)
- Reduce # of policies/roles
- Easier compliance audit
8. IAM Access Analyzer
Definition
A tool that analyzes IAM policies and identifies resources shared externally (public, cross-account, federated).
Findings
- S3 bucket accessible to all
- Lambda function exposed to other accounts
- KMS key shared with 3rd party
- IAM role assumable by external account
Features
- External access findings: detect unintended sharing
- Unused access findings: detect unused IAM roles/permissions (cost + security)
- Policy validation: validate IAM policy syntax + best practices
- Policy generation: generate least-privilege policy from CloudTrail events
Use case
- Continuous security audit
- Reduce attack surface
- Compliance (PCI, HIPAA)
9. IAM Roles Anywhere
Definition
IAM Roles Anywhere = on-prem servers (or other clouds) assume AWS IAM Roles using X.509 certificates (no long-term AWS keys).
Workflow
- Trust anchor: AWS Private CA or an external CA
- On-prem server has X.509 cert signed by trust anchor
- Server uses CreateSession API with cert → temp credentials
- Use temp creds to access AWS
Use case
- Hybrid workload (on-prem → AWS)
- CI/CD systems (Jenkins on-prem → AWS deploy)
- Replace stored access keys (security best practice)
10. IAM Best Practices (Top 15)
- Lock root user (MFA, no daily use)
- MFA for admin users
- Use IAM Roles (not access keys) for EC2, Lambda, ECS
- Apply least privilege
- Use AWS Identity Center for multi-account SSO
- Rotate access keys every 90 days
- Don't share credentials
- Audit with CloudTrail + Access Analyzer
- Permission boundaries for delegated admin
- Tag resources + use ABAC
- Federated identity instead of IAM users
- Strong password policy
- Enable IAM Roles Anywhere for hybrid
- Use Service Control Policies (Organizations)
- Regular review and cleanup unused users/roles
11. Common Patterns
Pattern 1: Cross-account access for CI/CD
CI account → Assume role in target account → Deploy resources
Pattern 2: Multi-account SSO via Identity Center
User → Identity Center login → Permission Set chosen → Auto-assume role in chosen account
Pattern 3: Mobile app + Cognito
User signup → User Pool → Identity Pool → AWS temp creds → API Gateway / DynamoDB
Pattern 4: Federated workload (on-prem CI)
Jenkins on-prem → X.509 cert → IAM Roles Anywhere → AWS deploy
Part 2: KMS and Secrets Manager
1. AWS KMS Overview
AWS KMS (Key Management Service) = a managed service that creates and manages cryptographic keys.
Characteristics
- Multi-tenant AES-256 encryption keys
- Integrates with 100+ AWS services
- FIPS 140-3 Level 3 (KMS HSMs reached Level 3 in 5/2023 — previously 140-2 Level 2)
- Audit logs in CloudTrail
- Regional (a key can only be used in the region where it was created)
Pricing
- $1/key/month (Customer-managed CMK)
- $0.03 per 10,000 API calls
- AWS-managed CMK: free
- Free tier: 20,000 API calls/month
2. KMS Key Types
Customer-Managed Key (CMK)
- You create, manage, rotate
- Full control over key policy, alias, deletion
- Pricing: $1/month + API calls
- Best for: granular control, audit, compliance
AWS-Managed Key
- AWS creates + manages it for a service (e.g.,
aws/s3,aws/rds) - Free
- View key in the console (read-only)
- Default for most AWS services
- Use case: Default encryption, no need for custom control
AWS-Owned Key
- Created by AWS, not visible in your account
- Used internally by services (DynamoDB encryption by default)
- Free
- Cannot be audited, cannot be disabled
Symmetric vs Asymmetric
| Symmetric (AES-256) | Asymmetric (RSA/ECC) | |
|---|---|---|
| Use case | Encrypt/decrypt data | Sign/verify, encrypt with public key |
| Encryption | Same key for both | Public encrypt, Private decrypt |
| Operations | Encrypt, Decrypt, GenerateDataKey | Sign, Verify, Encrypt, Decrypt |
| Most common | Default for most use cases | Code signing, JWT, certificates |
3. Envelope Encryption
Problem
- AES encryption is fast for small data
- A network call to KMS is slow for large data (4 KB limit per Encrypt call)
Solution: Envelope Encryption
- App calls KMS
GenerateDataKey→ returns:- Plaintext data key (for encryption)
- Encrypted data key (wrapped by CMK)
- App encrypts data locally with plaintext data key (fast)
- App stores encrypted data + encrypted data key
- App discards plaintext data key from memory
Decryption
- App reads encrypted data + encrypted data key
- App calls KMS
Decrypton encrypted data key → plaintext data key - App decrypts data locally
Benefit
- Limit KMS API calls (only encrypt/decrypt data key)
- Encrypt large data fast (locally)
- Most AWS services (S3 SSE-KMS, EBS) use envelope encryption
4. KMS Key Rotation
Automatic Rotation (Customer-managed CMK)
- Enable in the KMS console
- Rotation period: 90 days → 7 years, configurable (default 1 year) — April 2024 update
- Old key version kept (decrypt old ciphertext)
- New key version used for new encryption
- Free
- AWS-managed CMK: rotated every 1 year automatically (NOT configurable)
Manual Rotation
- Create new CMK
- Update alias to point to new key
- Old key stays for decrypting old data
5. KMS Multi-Region Keys
Definition
Multi-Region Keys = create replica of CMK in another Region, same key material.
Use case
- Cross-region applications (decrypt in any region)
- DR (failover to another region)
- Global Tables (DynamoDB), CRR (S3)
vs Single-Region
- Single-region: key bound to 1 region (must re-encrypt to use in another region)
- Multi-region: key works seamlessly across regions
6. KMS Key Policy
Definition
Key Policy = resource-based policy attached to KMS key (control WHO can use the key).
Default policy
- Allows root user full access
- Allows IAM policies attached to users/roles to grant access
Custom policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnableAdminAccess",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::111111111111:root" },
"Action": "kms:*",
"Resource": "*"
},
{
"Sid": "AllowUseOfKey",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::222222222222:role/AppRole" },
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:GenerateDataKey"
],
"Resource": "*"
}
]
}
7. KMS Key Deletion
Process
- Initiate "Schedule deletion"
- Waiting period: 7-30 days (default 30)
- During waiting period: key disabled (cannot encrypt/decrypt)
- After waiting period: permanently deleted
- Cancel deletion during waiting period possible
Best practice
- Long waiting period (30 days) for safety
- Disable key first, see if anything breaks
- DO NOT delete a key that has encrypted production data (you lose access permanently)
8. KMS Grants
Definition
Grant = temporary permission to use KMS key, programmatically created.
Use case
- AWS services on behalf of user (EBS create snapshot)
- Lambda function temporarily access KMS
- More granular than key policy
Properties
- Created/revoked via API
- Specifies operations, resources, conditions
- Up to 50,000 grants per key
9. AWS Secrets Manager
Definition
Secrets Manager = managed service to store, retrieve, rotate secrets (DB passwords, API keys).
Characteristics
- Automatic rotation (built-in for RDS, custom Lambda for others)
- KMS encryption (requires a CMK)
- Audit logs in CloudTrail
- Resource-based policy (cross-account access)
- Pricing: $0.40/secret/month + $0.05/10K API calls
Native rotation supported
- RDS: MySQL, PostgreSQL, MariaDB, Oracle, SQL Server
- Aurora
- DocumentDB, Redshift
- Custom Lambda function for other secrets
Rotation flow (RDS example)
- Lambda function rotates DB password
- Lambda updates secret in Secrets Manager
- Lambda updates DB user password
- App fetches new password from Secrets Manager
Use case
- Application secrets (API keys, OAuth tokens)
- Database credentials (with automated rotation)
- 3rd-party service credentials
10. Systems Manager Parameter Store
Definition
Parameter Store = store configuration data and secrets, integrated with SSM.
Characteristics
- Free (Standard tier, < 4 KB value, < 10K parameters)
- Advanced tier: $0.05/parameter/month, > 4 KB values
- Encryption via KMS (SecureString type)
- Hierarchical structure (
/app/dev/db/password) - No built-in rotation (manual or custom)
Types
- String: plain text
- StringList: comma-separated
- SecureString: encrypted with KMS
Use case
- App configuration (non-secret)
- Feature flags
- Database connection strings
- API endpoints
11. Secrets Manager vs Parameter Store
| Secrets Manager | Parameter Store | |
|---|---|---|
| Cost | $0.40/secret/month | Free (Standard), $0.05/param Advanced |
| Rotation | Built-in (RDS automatic) | Manual / custom Lambda |
| Cross-account | Yes (resource policy) | Via shared KMS key |
| Encryption | Always (KMS) | Optional (SecureString) |
| Max size | 64 KB | 4 KB (Standard), 8 KB (Advanced) |
| Versioning | Yes (5 versions kept) | Yes (Advanced) |
| Use case | Secrets needing rotation | Config + simple secrets |
Decision
- Secrets needing rotation: Secrets Manager
- Configuration data: Parameter Store (cheaper)
- Simple secrets, no rotation: Parameter Store SecureString (free)
12. AWS CloudHSM
Definition
CloudHSM = dedicated Hardware Security Module (HSM) in cloud, single-tenant.
Compared with KMS
| KMS | CloudHSM | |
|---|---|---|
| Tenancy | Multi-tenant | Single-tenant |
| Compliance | FIPS 140-3 L3 (since 5/2023) | FIPS 140-3 L3 |
| Control | AWS manages | Customer manages |
| Cost | $1/key/month | |
| Use case | General encryption | Strict compliance, custom crypto |
CloudHSM use cases
- Regulatory requires single-tenant HSM (some financial, government)
- Custom cryptographic algorithms
- BYOK (Bring Your Own Key) into KMS
- SSL/TLS offload for high volume
13. Common Patterns
Pattern 1: S3 with SSE-KMS + Bucket Key
- Encrypt objects with SSE-KMS
- Enable Bucket Key (reduce KMS API calls 99%)
Pattern 2: RDS with Secrets Manager + auto-rotation
- RDS uses Secrets Manager for password
- Rotate every 30 days automatic
- App fetches latest from Secrets Manager
Pattern 3: Application config in Parameter Store
- Lambda reads
/app/prod/api-endpointat cold start - Cache value in memory (avoid repeated calls)
Pattern 4: Cross-account secret sharing
- Resource policy on secret in Account A
- IAM policy in Account B allows GetSecretValue
- Shared via KMS key access
Part 3: ACM and CloudFront Security
1. AWS Certificate Manager (ACM)
Definition
ACM = managed SSL/TLS certificate service.
Characteristics
- Free for certs used with AWS services (CloudFront, ALB, NLB, API GW)
- Auto-renewal before expiry
- Supports public certs (DV - Domain Validation) and private certs (via AWS Private CA)
- Regional: a cert in a given region is used for services in that region (except CloudFront)
CloudFront special case
- CloudFront requires the cert to be in us-east-1 (N. Virginia)
- Because CloudFront is global, it uses us-east-1 as its "home"
Validation methods
- DNS validation (recommended): add a CNAME record to DNS
- Email validation: AWS sends an email to
admin@domain.com
Public cert workflow
1. Request certificate in ACM
2. Choose validation: DNS or Email
3. Validate ownership (add CNAME if DNS)
4. Cert issued (few minutes)
5. Deploy to ALB / CloudFront / API GW
6. Auto-renew 60 days before expire
Limitations
- Free public certs: you cannot export the private key (AWS use only)
- Need to export the private key → use AWS Private CA ($)
2. CloudFront Fundamentals
Definition
CloudFront = global CDN (Content Delivery Network) that caches content at 600+ edge locations.
Characteristics
- Low latency: serve content from the edge closest to the user
- DDoS protection: AWS Shield Standard included free
- Origin types:
- S3 bucket
- ALB / NLB
- EC2 / Custom HTTP origin
- API Gateway
- Lambda Function URL
- MediaStore / MediaPackage
- HTTPS: SSL via ACM
- HTTP/2, HTTP/3 (QUIC) support
Pricing
- Pay per request + data transfer out (edge → user)
- Free tier: 1 TB data transfer out + 10M requests/month (forever free)
- Cheaper than direct S3/ALB data transfer
Cost optimization
- CloudFront data transfer out ($0.085/GB) cheaper than EC2 direct ($0.09/GB)
- Cache hits reduce origin load (the origin's bandwidth is billed separately)
3. CloudFront Distribution
Components
- Distribution: top-level config (e.g., d1234.cloudfront.net)
- Origins: backends (S3, ALB, ...)
- Behaviors: routing rules per path pattern
- Cache settings: TTL, headers, query strings to forward
- Security: WAF, signed URLs
Architecture
User → CloudFront Edge → Regional Edge Cache → Origin
(600+ locations) (~13 locations) (S3, ALB)
↓
Cache lookup
↓
Cache HIT → Serve from edge (fast)
Cache MISS → Fetch from origin → Cache → Serve
4. Caching Behavior
Cache Key
Combination of fields that uniquely identify a cached object:
- URL path (default)
- Optional: Query strings, headers, cookies
TTL (Time to Live)
- Default TTL: 24 hours
- Min/Max TTL: configurable
- Cache headers from origin:
Cache-Control: max-age=N,Expires: date
Cache invalidation
- Invalidate: remove from cache before TTL expires
- Pattern:
/images/*or specific path - First 1000 invalidations/month free, then $0.005/path
Best practice
- High TTL for static assets (CSS, JS, images): months
- Low TTL for dynamic content: seconds-minutes
- Cache versioning: add hash to filename (
app.v123.js) instead of invalidating
5. Origin Access Control (OAC)
Problem
If the S3 bucket is exposed publicly so CloudFront can access it → users can bypass CloudFront (access S3 directly, skipping WAF and the cache).
Solution: OAC
- CloudFront has an IAM identity and can send signed requests to S3
- The S3 bucket policy only allows access from the CloudFront distribution (via OAC)
- Block direct S3 access
OAC vs OAI (legacy)
- OAI (Origin Access Identity): older, supports only S3 buckets (SSE-S3)
- OAC (Origin Access Control): newer, supports S3 + SSE-KMS + CRR + Object Lambda
- Recommended: OAC for new distributions
Bucket policy example
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Principal": { "Service": "cloudfront.amazonaws.com" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::my-bucket/*",
"Condition": {
"StringEquals": {
"AWS:SourceArn": "arn:aws:cloudfront::111111111111:distribution/DIST_ID"
}
}
}]
}
6. CloudFront Signed URLs and Cookies
Use case
Restrict access to paid content (videos, downloads) — only authorized users.
Signed URL
- URL with a signature
- Access single file
- Generated with a private key
Signed Cookie
- Cookie with a signature
- Access multiple files (entire site or directory)
- Generated with a private key
Workflow
1. User requests content from app
2. App authenticates user, authorizes
3. App generates signed URL/cookie (using CloudFront key pair)
4. User uses signed URL/cookie to access CloudFront
5. CloudFront validates signature, serves content (or denies)
Trusted Signers vs Trusted Key Groups
| Trusted Signers (legacy) | Trusted Key Groups (modern) | |
|---|---|---|
| Key | Account root user | Public keys group |
| Recommended | No | Yes |
7. Geo Restriction
2 modes
- Whitelist: only allow listed countries
- Blacklist: block listed countries
Use case
- Compliance (copyright, licensing per country)
- Block adversarial regions
- Compliance (GDPR)
8. CloudFront with HTTPS
SSL/TLS termination
- HTTPS at edge: cert via ACM (us-east-1)
- HTTPS to origin: optional (recommended)
Cipher policies
- TLS 1.2 minimum (recommended)
- Modern policies: ECDHE, AES-GCM
9. CloudFront Functions vs Lambda@Edge
CloudFront Functions
- Lightweight JavaScript (~1 KB)
- Sub-millisecond execution
- Run at edge (all 600+ locations)
- Use case: simple header manipulation, URL rewrites, redirects
- Free tier: 2M requests/month
- No external network access
Lambda@Edge
- Full Lambda (Node.js, Python)
- Up to 5 seconds execution
- Run at Regional Edge Cache (~13 locations)
- Use case: complex logic, A/B testing, dynamic content
- Standard Lambda pricing
- Can call external services (DB, APIs)
Comparison
| CloudFront Functions | Lambda@Edge | |
|---|---|---|
| Language | JavaScript only | Node.js, Python |
| Memory | 2 MB | 128 MB - 10 GB |
| Max execution | 1 ms | 5-30 sec |
| Network access | No | Yes |
| Cost | Very cheap | Standard Lambda |
| Use case | Header rewrite, simple | Complex logic |
CloudFront events
- Viewer Request (before cache lookup)
- Origin Request (before forward to origin)
- Origin Response (after origin response)
- Viewer Response (before response to user)
10. CloudFront Patterns
Pattern 1: Static website (S3 + CloudFront)
S3 (private) ← OAC ← CloudFront ← User
SSL via ACM
WAF for security
Pattern 2: Dynamic + Static
Dynamic (api.example.com):
CloudFront → ALB → ECS
Static (cdn.example.com):
CloudFront → S3 (with OAC)
Pattern 3: Paid content
User → App (auth) → Generates signed URL
User → CloudFront (signed URL) → Origin
Pattern 4: A/B testing
User → CloudFront → Lambda@Edge (random pick A/B) → Origin A or B
11. CloudFront vs Global Accelerator
| CloudFront | Global Accelerator | |
|---|---|---|
| Use case | HTTP/HTTPS content caching | Non-HTTP (TCP/UDP), routing |
| Caching | Yes | No |
| Static IPs | No (DNS) | Yes (2 anycast) |
| Protocols | HTTP, HTTPS | TCP, UDP |
| Use case examples | Web content, video streaming | Gaming, IoT, financial |
Review Questions
-
What is the STS token lifetime range?
Show answer
15 minutes to 12 hours for AssumeRole (default 1 hour). For AssumeRoleWithWebIdentity and AssumeRoleWithSAML: up to 1 hour. Federated user sessions can last up to 36 hours. The maximum role session duration is configured in the role settings (max 12 hours). Shorter tokens = better security; longer tokens = fewer calls to STS.
-
Does a Permission Boundary grant permissions?
Show answer
No — a Permission Boundary only limits the maximum permissions (a ceiling); it does not grant permissions by itself. The identity still needs its own identity-based policy to actually have access. Example: the Boundary allows S3+EC2, the identity policy allows S3+DynamoDB → the effective permission is only S3 (intersection). Use Boundaries to delegate IAM administration: let teams create roles without exceeding a defined scope.
-
When you share an IAM role with a 3rd-party vendor, which feature do you use to protect it?
Show answer
External ID in the trust policy (Confused Deputy protection). When the vendor assumes the role it must provide the External ID secret — this prevents an attacker from tricking the vendor into accessing your account using the vendor's AWS credentials. The External ID is a secret known only to you and the vendor, included in the
sts:ExternalIdcondition. Best practice for all cross-account third-party integrations. -
How does ABAC differ from RBAC?
Show answer
RBAC (Role-Based): access is based on roles (IAM Roles/Groups) — you create many roles for many resource combinations, which gets complex at scale. ABAC (Attribute-Based): access is based on the tags of both the identity and the resource — one policy can cover many resources:
"Condition": {"StringEquals": {"aws:ResourceTag/Project": "${aws:PrincipalTag/Project}"}}. A good fit for large-scale multi-team environments — fewer policies, easier to manage. -
What does IAM Access Analyzer help you detect?
Show answer
Access Analyzer analyzes resource-based policies (S3, SQS, KMS, Lambda, IAM roles) to find external access — resources shared with principals outside the account/Organization. It highlights unintended public access (public S3 bucket, role assumable from the internet). It also has External Access findings for cross-account access and Unused Access findings (over-permissive policies). It runs continuously — alerting when something new is detected.
-
What problem does Envelope Encryption solve?
Show answer
It solves the performance and data size limits of KMS. KMS can only encrypt data up to 4 KB directly. Envelope Encryption: (1) KMS generates a Data Encryption Key (DEK), (2) the DEK encrypts the actual data (locally, fast, no size limit), (3) the DEK is encrypted with the KMS CMK and stored alongside the data. To decrypt: call KMS to decrypt the DEK, then use the DEK to decrypt the data. Only the DEK travels over the network to KMS — large data is processed locally.
-
How often does KMS Key auto-rotation rotate?
Show answer
1 year (365 days) for AWS-managed keys and customer-managed keys (when auto-rotation is enabled). Customer-managed keys can configure rotation from 90 days to 2,560 days (7 years). Auto-rotation only rotates the key material — the Key ID doesn't change, so you don't need to update references. Data encrypted with the old key can still be decrypted (KMS keeps the old key material).
-
How long is the KMS Key deletion waiting period?
Show answer
7 to 30 days (configurable). You cannot delete a key immediately — the waiting period lets you detect and cancel if the key is still in use. During this period the key is disabled (cannot be used to encrypt/decrypt). If you cancel before the waiting period ends, the key works normally again. After deletion, data encrypted with that key cannot be decrypted — it is lost permanently.
-
What is the core difference between Secrets Manager and Parameter Store?
Show answer
Secrets Manager: automatic rotation of secrets (RDS, Redshift, DocumentDB, custom), and it has a cost ($0.40/secret/month + $0.05/10K API calls). Use it for database credentials and API keys that need rotation. Parameter Store: stores configuration and secrets (SecureString = encrypted), has no built-in auto-rotation, and is cheaper (Standard: free; Advanced: $0.05/10K requests). Use it for application config and non-rotating secrets. Lambda/ECS integrate well with both.
-
When do you use CloudHSM instead of KMS?
Show answer
Use CloudHSM when: (1) You need sole tenancy of the hardware HSM (not shared with AWS or other customers), (2) You need full control of key material — KMS manages key material and you cannot export it, (3) You need custom cryptographic algorithms or SSL/TLS offload, (4) Compliance regulations require a dedicated HSM (PCI DSS, certain government). Note: since 5/2023 KMS has also reached FIPS 140-3 Level 3, so the FIPS level is no longer a reason to choose CloudHSM (older exams/materials often say "KMS is only Level 2"). CloudHSM is more expensive (~$1.45-1.60/hour/HSM depending on region) and requires more management.
- In which Region must the ACM cert for CloudFront be?
Show answer
us-east-1 (N. Virginia) — CloudFront is a global service but only reads ACM certificates from us-east-1. If you provision the cert in another Region, CloudFront won't see it. This is a common real-world mistake: a team provisions the cert in ap-southeast-1 and CloudFront can't find it. Certs for ALB/API GW can be provisioned in the Region of that resource.
- How does OAC differ from OAI? When do you use OAC?
Show answer
OAI (Origin Access Identity): legacy, standard S3 only, no support for SSE-KMS encryption. OAC (Origin Access Control): the new generation, supports S3 + SSE-KMS encrypted objects, cross-account, and HTTP method signing. AWS recommends using OAC instead of OAI for all new deployments. Both let CloudFront access a private S3 bucket without public access.
- What is the difference between a CloudFront Signed URL and a Signed Cookie?
Show answer
Signed URL: restricts access to 1 specific file — the URL contains the signature, expiry, IP restrictions. Suitable for sharing a download link for 1 file. Signed Cookie: restricts access to multiple files within the same session — the browser sends the cookie with every request. Suitable for premium content, video streaming (many segments), or when the URL needs to stay clean (you don't want to append a signature to the URL).
- CloudFront Functions vs Lambda@Edge: which one allows external network calls?
Show answer
Only Lambda@Edge — it can call external APIs, DynamoDB, Secrets Manager. CloudFront Functions: no network access, no filesystem, execution time < 1ms, much cheaper (~1/6 the price). Suitable for lightweight operations: URL rewrite, header manipulation, simple A/B routing. Lambda@Edge: CPU-intensive, complex logic, needs external data, max 5-30 seconds execution.
- When do you use CloudFront vs Global Accelerator?
Show answer
CloudFront: optimized for HTTP/HTTPS workloads with cacheable content — websites, APIs, static assets. CloudFront caches at Edge Locations. Global Accelerator: optimized for any TCP/UDP traffic (gaming, IoT, VoIP), no caching, when you need static IP addresses (NLB-fronting), or need to route non-HTTP traffic. Global Accelerator also supports HTTP but doesn't cache — suitable for dynamic content, health routing between regions.
Hands-on Exercises
Part 1: Advanced IAM
- Create a cross-account role: an Account A user assumes a role in Account B
- Set up IAM Identity Center (free), assign a Permission Set
- Create a Permission Boundary that limits the user to only creating IAM roles with the boundary attached
- Test ABAC: a user with tag Department=eng accesses EC2 with tag Department=eng
- Enable IAM Access Analyzer, review findings
Part 2: KMS and Secrets Manager
- Create a Customer-Managed CMK, enable auto-rotation
- Encrypt an S3 bucket with SSE-KMS, observe envelope encryption
- Create a secret in Secrets Manager for the RDS password, enable auto-rotation every 30 days
- Create a Parameter Store SecureString for an API key, retrieve it via CLI
- Create a Multi-Region KMS key, replicate it to another region
Part 3: ACM and CloudFront Security
- Request an ACM cert for a domain in us-east-1 (DNS validation)
- Set up a CloudFront distribution with an S3 origin + OAC
- Test that direct S3 access is denied and access through CloudFront succeeds
- Create a signed URL for 1 object, expiring in 1 hour
- Set up a Geo Restriction blacklist for 2 countries
- Create a CloudFront Function that rewrites the URL
/api→/v2/api
References
- IAM User Guide
- STS
- Permission Boundaries
- ABAC
- IAM Access Analyzer
- IAM Identity Center
- KMS Developer Guide
- Envelope Encryption
- Multi-Region Keys
- Secrets Manager
- Parameter Store
- CloudHSM
- AWS Certificate Manager
- CloudFront Developer Guide
- Origin Access Control
- Signed URLs/Cookies
- CloudFront Functions