Scenario Questions
Real-world AWS situations and how to reason through them in an interview
IAM, Organizations and Multi-Account
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q1 A developer needs read-only access to one S3 bucket from their laptop. How do you grant it without creating long-lived access keys?
Beginner
Situation read โ Human access to AWS should be federated and short-lived; an IAM user with static keys is the thing auditors flag first.
What I'd do โ
- Put the person in IAM Identity Center (SSO) and create a permission set with a scoped policy for that bucket
- Assign the permission set to the user or group for the target account
- Developer runs
aws configure ssothenaws sso login --profile dev - Verify with
aws s3 ls s3://app-reports --profile devandaws sts get-caller-identity
Why โ SSO credentials expire in hours, access is revoked centrally when the person leaves, and CloudTrail shows the SSO role session name.
Interview tip โ Say "no IAM users for humans" early; it signals you know the modern baseline.
Q2 An EC2 application needs to write to DynamoDB. Where do the credentials come from?
Beginner
Situation read โ Never bake keys into the AMI or env vars; the instance should assume a role through its instance profile.
What I'd do โ
- Create a role trusting
ec2.amazonaws.comwith a policy limited todynamodb:PutItemon the table ARN - Create an instance profile and attach it:
aws ec2 associate-iam-instance-profile --instance-id i-0abc --iam-instance-profile Name=orders-app - Use the default SDK credential chain in code, with no keys configured
- Enforce IMDSv2 so SSRF cannot trivially steal the role credentials
Why โ The SDK fetches rotating credentials from IMDS automatically, so there is nothing to leak or rotate by hand.
Interview tip โ Mention IMDSv2 HttpTokens=required; it shows security awareness beyond "use a role".
Q3 Security wants to know who deleted a production S3 bucket yesterday. How do you find out?
Beginner
Situation read โ This is a CloudTrail question; bucket deletion is a management event, recorded by default for 90 days.
What I'd do โ
- Open CloudTrail Event history and filter on Event name
DeleteBucket - Or CLI:
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=DeleteBucket - Read
userIdentity,sourceIPAddressanduserAgentto identify the principal - For longer history query the trail's S3 logs with Athena
Why โ Event history only covers 90 days of management events in one region view, so an organization trail to S3 is what actually keeps the evidence.
Interview tip โ Distinguish management events from data events (object-level), which are off by default.
Q4 You must stop anyone in a member account from disabling CloudTrail, even account admins. What do you use?
Beginner
Situation read โ IAM policies inside the account cannot restrain the account admin, so the control belongs above the account, in Organizations.
What I'd do โ
- Create an SCP that denies
cloudtrail:StopLogging,cloudtrail:DeleteTrailandcloudtrail:UpdateTrail - Attach it to the OU holding workload accounts
- Test from a member account admin: the call should fail with an explicit deny from the SCP
- Keep break-glass in the management account, which SCPs do not affect
Why โ SCPs set the maximum permissions boundary for every principal in the account except the management account.
Interview tip โ Remember SCPs never grant anything; they only filter.
Q5 A cross-account role assumption fails with AccessDenied even though the target role trusts the source account. What do you check?
Intermediate
Situation read โ Both sides must allow it: the target trust policy and an identity policy on the caller granting sts:AssumeRole.
What I'd do โ
- Check the role's trust policy principal and any
Conditionsuch assts:ExternalIdoraws:PrincipalOrgID - Check the caller's identity policy allows
sts:AssumeRoleon the exact role ARN - Check no SCP or permissions boundary blocks it
- Retry:
aws sts assume-role --role-arn arn:aws:iam::222222222222:role/deploy --role-session-name testand read the error text
Why โ Cross-account needs an allow on both sides, whereas same-account trust can be satisfied by one.
Interview tip โ Mention that a trust principal of the account root only delegates; the caller still needs its own allow.
Q6 Design access for a CI pipeline in GitHub Actions to deploy to AWS without storing AWS keys in GitHub.
Intermediate
Situation read โ OIDC federation lets GitHub present a signed token that AWS exchanges for temporary role credentials.
What I'd do โ
- Create an IAM OIDC provider for
token.actions.githubusercontent.comwith audiencests.amazonaws.com - Create a deploy role whose trust policy uses
sts:AssumeRoleWithWebIdentityand a conditiontoken.actions.githubusercontent.com:subequal torepo:acme/shop:ref:refs/heads/main - In the workflow set
permissions: id-token: writeand useaws-actions/configure-aws-credentialswithrole-to-assume - Scope the role policy to only the resources it deploys
Why โ No secret exists to steal, tokens last about an hour, and the sub condition ties the role to one repo and branch.
Interview tip โ Call out that a missing sub condition lets any repo on GitHub assume the role.
Q7 How would you let developers create IAM roles for their apps without letting them escalate to admin?
Intermediate
Situation read โ This is the classic delegated-administration problem; solve it with permissions boundaries.
What I'd do โ
- Define a boundary policy that caps what any app role can ever do (for example no IAM, no Organizations)
- Give developers
iam:CreateRoleandiam:AttachRolePolicyonly with conditioniam:PermissionsBoundaryequal to the boundary ARN - Deny
iam:DeleteRolePermissionsBoundary - Prefix-scope with a path such as
role/app/*
Why โ Effective permissions are the intersection of identity policy and boundary, so any role they create stays inside the cage.
Interview tip โ Name the escalation path you are blocking: create a role with AdministratorAccess and assume it.
Q8 Your company has 40 AWS accounts. How do you structure them and why?
Intermediate
Situation read โ One account is a blast-radius and billing boundary; a landing zone separates concerns from day one.
What I'd do โ
- Use AWS Organizations with OUs: Security (log archive, audit), Infrastructure (network, shared services), Workloads split into prod and non-prod, Sandbox
- Deploy with Control Tower or Landing Zone Accelerator for guardrails
- Centralize CloudTrail, Config and GuardDuty into the security accounts
- Attach SCPs per OU such as region restriction and deny leaving the org
Why โ Separate prod and non-prod accounts give strong IAM and quota isolation that tags and policies in one account cannot.
Interview tip โ Say "account per workload per environment" and be ready to defend the cost of more accounts.
Q9 An access key for an IAM user was committed to a public GitHub repo 20 minutes ago. Walk through your response.
Intermediate
Situation read โ Assume it is already scraped; speed matters more than forensics at first, but preserve evidence.
What I'd do โ
- Deactivate the key immediately:
aws iam update-access-key --user-name ci-bot --access-key-id AKIA... --status Inactive - Attach an explicit deny-all policy or use the AWSCompromisedKeyQuarantine policy AWS may have applied
- Query CloudTrail for the key id over the exposure window for unusual calls like
RunInstancesin odd regions - Terminate rogue resources, check for new IAM users, roles and access keys
- Create a replacement via a role or OIDC, then delete the old key and purge it from git history
Why โ Deactivate before delete so you can still audit the key and roll back if a legitimate system breaks.
Interview tip โ Mention enabling secret scanning push protection to prevent a repeat.
Q10 A Lambda function cannot read an S3 bucket in another account even though the bucket policy allows the role. Why?
Intermediate
Situation read โ Cross-account S3 access requires the identity policy in the caller account and the bucket policy to both allow, and KMS if the objects are encrypted.
What I'd do โ
- Confirm the Lambda execution role has
s3:GetObjecton the bucket ARN and object path - Confirm the bucket policy principal is the role ARN, not just the account root
- If SSE-KMS, check the key policy and the role's
kms:Decrypton that key - Check the bucket for Block Public Access or a VPC endpoint policy denying the call
Why โ Missing KMS permission produces an AccessDenied that looks identical to a missing S3 permission, which wastes hours.
Interview tip โ Always ask "is the object KMS-encrypted?" first in cross-account S3 problems.
Q11 Design break-glass access for production that is audited, time-bound, and not a shared password.
Advanced
Situation read โ Break-glass must exist and be loud; the failure modes are shared credentials and no alarm.
What I'd do โ
- Create a dedicated
BreakGlassAdminpermission set in Identity Center, assigned to a small group, with session duration 1 hour - Require MFA with phishing-resistant keys
- EventBridge rule on the
AssumeRoleorCreateCredentialevents for that role pages the on-call and posts to the security channel - Keep two root account credentials sealed offline with hardware MFA for the case SSO itself is down
- Quarterly drill, then review the CloudTrail trail of every use
Why โ Auditability plus alerting turns emergency access into an accountable action rather than a backdoor.
Interview tip โ Mention you also test it, since untested break-glass fails when needed.
Q12 You need to guarantee no resources are ever created outside eu-west-1 and eu-central-1 across the org. What is the design and the pitfalls?
Advanced
Situation read โ Region restriction is an SCP job, but global services make a naive deny break things.
What I'd do โ
- Write an SCP with
DenyandNotActionlisting global services (IAM, Organizations, Route 53, CloudFront, Support, STS) - Condition
StringNotEqualsonaws:RequestedRegionfor the two allowed regions - Add exception for control-plane roles such as the Control Tower execution role via
ArnNotLikeonaws:PrincipalARN - Apply to a test OU first and watch CloudTrail for denied calls
Why โ Using Action: * without carving out global endpoints in us-east-1 breaks IAM, billing and CloudFront calls.
Interview tip โ Mention opt-in regions and that the CloudFront and ACM-for-CloudFront certificate must live in us-east-1.
Q13 Two accounts need private access to each other's APIs, with overlapping CIDRs. What do you build?
Advanced
Situation read โ Overlapping CIDRs rule out VPC peering and Transit Gateway routing, so expose services rather than networks.
What I'd do โ
- In the provider account put the service behind an NLB and create a VPC endpoint service with
aws ec2 create-vpc-endpoint-service-configuration --network-load-balancer-arns ... - Whitelist the consumer account principal and require acceptance
- In the consumer account create an interface endpoint to the service name
- Consumer calls the endpoint's private DNS name, unaffected by CIDR overlap
Why โ PrivateLink is one-directional and NAT-less at the packet level, so address overlap never matters.
Interview tip โ Contrast: peering and TGW share routes, PrivateLink shares a service.
Q14 The audit team requires that every S3 bucket in the org is encrypted and not public. How do you enforce and detect?
Intermediate
Situation read โ Combine preventive controls (SCP, account settings) and detective controls (Config).
What I'd do โ
- Turn on S3 Block Public Access at the account level via
aws s3control put-public-access-blockand enforce through an SCP denying its removal - Enable default SSE-S3 or SSE-KMS (default on since 2023) and add a bucket-policy or SCP that denies
s3:PutObjectwithout the expected encryption header when KMS is required - Deploy Config managed rules
s3-bucket-public-read-prohibitedands3-bucket-server-side-encryption-enabledthrough an org conformance pack - Auto-remediate with SSM Automation
Why โ Prevent what you can, detect the rest; either alone leaves gaps.
Interview tip โ Mention Security Hub CSPM standards for an aggregated score.
Q15 What is the difference between an IAM role and an IAM user, and when do you pick each?
Beginner
Situation read โ A user is a long-lived identity with static credentials; a role is an assumable identity with temporary credentials.
What I'd do โ
- Use roles for EC2, Lambda, ECS tasks, cross-account access and CI
- Use SSO-federated roles for humans
- Reserve IAM users for rare cases like a third-party tool that cannot federate, and then rotate keys and restrict by condition
- Audit with the credential report:
aws iam generate-credential-report
Why โ Temporary credentials shrink the window of a leak from forever to hours.
Interview tip โ One-line answer: "roles for everything, users almost never".
Q16 A teammate says "just give it AdministratorAccess to get unblocked". How do you handle it properly?
Beginner
Situation read โ Least privilege can be reached fast by letting AWS tell you what the app actually used.
What I'd do โ
- Allow the broad permission only in a dev account for a short window
- Run the workload, then use IAM Access Analyzer policy generation from CloudTrail: it builds a policy from observed calls
- Review the draft, replace wildcards with ARNs, and apply it
- Remove the admin policy and check
aws iam get-rolefor attached policies
Why โ Generated policies come from real activity so they are tighter than guesses.
Interview tip โ Mention Access Analyzer unused-access findings for cleanup later.
Q17 A policy has an Allow for s3:* but a user still gets AccessDenied on PutObject. List the places a deny can hide.
Intermediate
s3:* but a user still gets AccessDenied on PutObject. List the places a deny can hide.Situation read โ Evaluation is explicit deny first, so I hunt for any deny across the layers.
What I'd do โ
- SCP in Organizations
- Permissions boundary on the role or user
- Session policy passed during assume-role
- Bucket policy with
Denyconditions such asaws:SecureTransportor required encryption - VPC endpoint policy
- Use the IAM policy simulator or
aws iam simulate-principal-policyand CloudTrailerrorMessage, which often names the deny type
Why โ AWS error messages now say "explicit deny in a service control policy" or similar, which pinpoints the layer.
Interview tip โ Recite the evaluation order: explicit deny, SCP, boundary, session, identity or resource allow.
Q18 How do you give an on-premises server AWS access without IAM users?
Intermediate
Situation read โ IAM Roles Anywhere issues temporary credentials against X.509 certificates, or SSM hybrid activation covers management tasks.
What I'd do โ
- Create a trust anchor from your private CA or ACM Private CA
- Create a profile mapping to an IAM role
- Install
aws_signing_helperon the server and configurecredential_processin the AWS profile - Restrict the trust policy with a condition on the certificate subject
Why โ The server proves identity by certificate rather than a stored secret, and credentials rotate automatically.
Interview tip โ Mention certificate lifecycle as the new operational burden.
Q19 A product team wants to give an external vendor limited access to one account. Design it safely.
Advanced
Situation read โ Third-party access must prevent the confused deputy problem and be revocable.
What I'd do โ
- Create a role in your account trusting the vendor's account with
sts:ExternalIdcondition set to a unique value you generate - Attach a narrowly scoped policy plus a permissions boundary
- Require
aws:MultiFactorAuthPresentonly if their human flow supports it, otherwise limit byaws:SourceIp - Alert on the role's use via CloudTrail and set
MaxSessionDurationto 1 hour
Why โ ExternalId stops another customer of the same vendor from tricking the vendor into using your role.
Interview tip โ Say "confused deputy" by name.
Q20 The finance team asks for monthly cost by team. How do you structure IAM and tagging to make that possible?
Intermediate
Situation read โ Attribution needs enforcement at creation time, not a spreadsheet after the fact.
What I'd do โ
- Define tag keys (
team,env,cost-center) and activate them as cost allocation tags in Billing - Enforce with an SCP or tag policy and IAM condition
aws:RequestTag/teamon create actions - Use an AWS Config rule
required-tagsto catch drift - Use account-per-team where possible, since account boundary is the cleanest chargeback
Why โ Untagged resources become unallocatable spend that nobody owns.
Interview tip โ Mention that some services (data transfer, shared EKS) need split allocation tooling.
Q21 Your SCP change accidentally locked everyone out of a production OU, including the pipeline. How do you recover?
Advanced
Situation read โ SCPs do not apply to the management account, which is the recovery path.
What I'd do โ
- Sign in to the management account with an admin who has Organizations permissions
- Detach or fix the SCP:
aws organizations detach-policy --policy-id p-xxxx --target-id ou-abcd-12345678 - Verify member-account calls work again
- Add a post-mortem action to roll out SCPs to a canary OU first with CloudTrail review
Why โ Management account is exempt by design, which is also why you must keep workloads out of it.
Interview tip โ Always keep FullAWSAccess attached alongside deny lists unless you intentionally use allow-list mode.
Q22 How do you rotate IAM access keys used by a legacy app you cannot refactor quickly?
Intermediate
Situation read โ Two keys per user permit zero-downtime rotation; automation prevents it from being forgotten.
What I'd do โ
- Create the second key:
aws iam create-access-key --user-name legacy-app - Store it in Secrets Manager and update the app configuration
- Confirm via
aws iam get-access-key-last-usedthat the new key is in use - Deactivate then delete the old key
- Schedule it with a Lambda or Secrets Manager rotation template, and alert via Config rule
access-keys-rotated
Why โ Overlap eliminates the outage window that makes teams avoid rotation.
Interview tip โ Offer the long-term fix: move the app to a role.
Q23 What does MFA enforcement for the console look like in a shared account, and how do you require it for API calls too?
Beginner
Situation read โ Console MFA is easy; API MFA is enforced via a policy condition.
What I'd do โ
- Use SSO with MFA enforced in Identity Center settings
- For remaining IAM users attach a policy denying all except MFA-device management when
aws:MultiFactorAuthPresentis false - For API use, users call
aws sts get-session-token --serial-number arn:aws:iam::111111111111:mfa/alice --token-code 123456 - Prefer hardware or passkey MFA for admins
Why โ The deny-unless-MFA pattern gives enforcement even when the user has valid keys.
Interview tip โ Mention root user MFA and no root access keys as the first hygiene items.
Q24 An engineer left the company. How do you make sure nothing of theirs still works?
Intermediate
Situation read โ Offboarding is easy if identity is centralized, hard if they created IAM users or keys.
What I'd do โ
- Disable the user in the IdP, which kills SSO sessions into every account
- Run the credential report to find any IAM users or keys:
aws iam get-credential-report - Search for roles they created with trust to personal accounts
- Rotate any shared secrets they knew
- Check CloudTrail for the user's actions the final week
Why โ Central IdP removal handles 95 percent of access; the remainder is the shadow credentials.
Interview tip โ Mention periodic IAM Access Analyzer external-access findings.
Q25 Walk me through how you would implement least privilege at scale for 200 roles that currently have wide permissions.
Advanced
Situation read โ You cannot hand-review 200 roles, so use data to shrink them in waves.
What I'd do โ
- Enable Access Analyzer unused-access analyzer at the org level
- Rank roles by findings of unused permissions and unused roles
- Generate policies from CloudTrail for the top risks, replace with scoped ones in lower environments first
- Roll to prod behind a monitored change window with the old policy kept for rollback
- Add policy-as-code checks (IAM Access Analyzer
validate-policyor cfn-guard) in CI
Why โ Iterative tightening with rollback beats a big-bang rewrite that breaks production.
Interview tip โ Mention that you measure progress by unused-permission count dropping.
VPC and Networking
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q26 You are asked to design a VPC for a three-tier web app. What does the layout look like?
Beginner
Situation read โ Public only for what must face the internet; everything else private across at least two AZs.
What I'd do โ
- Pick a /16 such as
10.20.0.0/16and carve /20 or /24 subnets per tier per AZ - Public subnets hold ALB and NAT gateways, private app subnets hold compute, isolated data subnets hold RDS with no internet route
- Route tables: public to IGW, private to NAT, data with local only
- Security groups chained: ALB to app to DB by SG reference
Why โ Tier isolation and SG referencing limit lateral movement and keep rules readable.
Interview tip โ Leave spare CIDR space; resizing a VPC later hurts.
Q27 Instances in a private subnet cannot reach the internet to download packages. What do you add?
Beginner
Situation read โ Private subnets need an outbound path, typically a NAT gateway in a public subnet.
What I'd do โ
- Create a NAT gateway in a public subnet with an Elastic IP
- Add
0.0.0.0/0 -> nat-0abcto the private route table - Test from the instance:
curl -sI https://example.com - For one NAT per AZ, add one route table per AZ
Why โ NAT gives outbound-only access; inbound connections from the internet still cannot be initiated.
Interview tip โ Mention NAT cost and the gateway endpoint alternative for S3 and DynamoDB.
Q28 Your NAT gateway bill is $4,000 a month. How do you cut it?
Intermediate
Situation read โ NAT charges per hour and per GB; most heavy traffic is usually to AWS services or ECR and S3.
What I'd do โ
- Use VPC Flow Logs or CloudWatch metric
BytesOutToDestinationto find top talkers - Add free gateway endpoints for S3 and DynamoDB
- Add interface endpoints for ECR, STS, CloudWatch Logs where traffic is high, since endpoint per-GB cost is lower than NAT
- Keep chatty cross-AZ traffic in the same AZ as its NAT
- Consider NAT instances only for dev environments
Why โ Most NAT spend is avoidable traffic to AWS public endpoints.
Interview tip โ Mention that cross-AZ data transfer through NAT adds a second charge.
Q29 What is the difference between a security group and a network ACL, and when would you touch NACLs?
Beginner
Situation read โ SGs are stateful and attach to ENIs; NACLs are stateless and attach to subnets.
What I'd do โ
- Default to SGs for all allow rules
- Use NACLs for coarse subnet-wide denies such as blocking a hostile CIDR
- Remember NACL rules need both inbound and outbound with ephemeral ports
1024-65535 - Inspect:
aws ec2 describe-network-acls --filters Name=vpc-id,Values=vpc-0abc
Why โ SG rules are allow-only, NACLs support explicit deny and are evaluated in rule-number order.
Interview tip โ State the "stateful vs stateless" contrast first.
Q30 Connect 30 VPCs across 10 accounts with shared on-prem connectivity. VPC peering or Transit Gateway?
Intermediate
Situation read โ Peering is non-transitive and creates a mesh; TGW is a hub with route tables.
What I'd do โ
- Create a TGW in the network account and share it with RAM across the org
- Attach each VPC and the VPN or Direct Connect gateway
- Use separate TGW route tables to segment prod from dev
- Add VPC route
10.0.0.0/8 -> tgw-0abcand test with Reachability Analyzer
Why โ Peering scales as n squared; TGW scales linearly and supports central egress and inspection.
Interview tip โ Know the TGW cost: per attachment per hour plus per GB.
Q31 Design hybrid connectivity to on-prem that survives a link failure.
Intermediate
Situation read โ Redundancy must exist at the device, circuit and path level.
What I'd do โ
- Primary: Direct Connect, ideally two connections at different locations
- Backup: Site-to-Site VPN over the internet attached to the same Transit Gateway or Virtual Private Gateway
- Use BGP on both with local preference or AS-path prepending favoring DX
- Enable BFD and test failover by shutting one path
- Monitor
TunnelStateand DXConnectionStatemetrics
Why โ DX gives predictable latency; VPN gives fast, cheap insurance with automatic BGP failover.
Interview tip โ A single DX is a single point of failure; say so.
Q32 Traffic from your VPC to S3 goes through the NAT gateway. How do you keep it on the AWS network and add control?
Intermediate
Situation read โ A gateway endpoint routes S3 traffic privately and allows policy control at no charge.
What I'd do โ
- Create the endpoint:
aws ec2 create-vpc-endpoint --vpc-id vpc-0abc --service-name com.amazonaws.eu-west-1.s3 --route-table-ids rtb-0abc - Attach an endpoint policy restricting access to your buckets
- Add a bucket policy condition
aws:SourceVpceso the bucket is only reachable through the endpoint - Verify with
tracerouteor route table entry for the prefix list
Why โ The endpoint adds a prefix-list route that wins over the default route, so NAT is bypassed.
Interview tip โ Gateway endpoints exist only for S3 and DynamoDB; everything else uses interface endpoints.
Q33 You must inspect all egress traffic from 50 VPCs centrally. What is the architecture?
Advanced
Situation read โ Centralized egress with an inspection VPC behind Transit Gateway.
What I'd do โ
- Spoke VPCs send
0.0.0.0/0to the TGW - TGW route table for spokes points to an inspection VPC attachment with appliance mode enabled
- Inspection VPC runs AWS Network Firewall or third-party firewalls behind a Gateway Load Balancer
- Firewall subnets forward to NAT gateways in an egress VPC
- Return path via TGW; enable flow logs on all attachments
Why โ Appliance mode keeps both directions of a flow on the same AZ so stateful inspection works.
Interview tip โ Mention the cost and single-choke-point trade-off versus per-VPC firewalls.
Q34 Two services in different AZs talk constantly and the cross-AZ data transfer charge is rising. What do you do?
Intermediate
Situation read โ Cross-AZ traffic costs about a cent per GB each direction, which adds up for chatty tiers.
What I'd do โ
- Identify with Cost Explorer usage type
DataTransfer-Regional-Bytesand flow logs - Prefer zone-aware routing: Kubernetes topology-aware routing or ALB zonal affinity
- Keep caches and replicas per AZ
- Accept cross-AZ for HA-critical paths such as DB replication
- Re-measure after the change
Why โ Resilience needs multi-AZ, but balancing locality and failover captures savings.
Interview tip โ Don't suggest single-AZ for production just to save money.
Q35 A new subnet's instances cannot be reached via SSH from the internet. Walk through the checks.
Beginner
Situation read โ Connectivity needs an IGW route, a public IP, an SG rule and a NACL that allows it.
What I'd do โ
- Subnet route table has
0.0.0.0/0 -> igw-... - Instance has a public or Elastic IP
- SG allows TCP 22 from your IP
- NACL allows inbound 22 and outbound ephemeral ports
- Better, remove public SSH entirely and use SSM Session Manager:
aws ssm start-session --target i-0abc
Why โ Each layer can independently block; checking in packet order finds the break quickly.
Interview tip โ Suggest Session Manager as the modern replacement.
Q36 How would you give private instances access to AWS Systems Manager without NAT or public IPs?
Intermediate
Situation read โ SSM needs three interface endpoints in the VPC.
What I'd do โ
- Create endpoints
ssm,ssmmessagesandec2messageswith private DNS enabled - Attach an SG allowing 443 from the instance subnets
- Ensure the instance role has
AmazonSSMManagedInstanceCore - Test: instance appears in
aws ssm describe-instance-information
Why โ Instances reach SSM purely on the AWS backbone, shrinking attack surface.
Interview tip โ Forgetting ssmmessages is the usual reason Session Manager fails.
Q37 Two VPCs peered, but the app in VPC A cannot reach VPC B's database. What is the routine?
Intermediate
Situation read โ Peering needs routes on both sides plus SG and DNS settings.
What I'd do โ
- Check peering is
active:aws ec2 describe-vpc-peering-connections - Add routes in both VPC route tables to the peer CIDR
- Check the DB SG allows the source CIDR or the peer SG reference (cross-account SG references work only in the same region)
- Check NACLs
- Enable DNS resolution over peering if using private hostnames
Why โ Peering creates a path only; routing and filtering are still your job.
Interview tip โ Peering never routes through a third VPC.
Q38 Design IPv6 adoption for a dual-stack app to reduce NAT costs.
Advanced
Situation read โ IPv6 addresses are globally routable, so private egress uses an egress-only internet gateway instead of NAT.
What I'd do โ
- Associate an Amazon-provided /56 with the VPC and /64 with subnets
- Add
::/0 -> eigw-0abcin private route tables - Enable dual-stack on the ALB (
--ip-address-type dualstack) - Update SGs with IPv6 rules
- Keep NAT64 and DNS64 for IPv4-only destinations
Why โ IPv6 egress via EIGW has no hourly or per-GB NAT fee, and public IPv4 addresses now cost money too.
Interview tip โ Remember that public IPv4 charges began in 2024; it drives IPv6 interest.
Q39 An application needs a stable outbound IP that a partner can whitelist. How?
Intermediate
Situation read โ Outbound IPs come from NAT gateway Elastic IPs, which are stable.
What I'd do โ
- Create a NAT gateway with an allocated EIP in each AZ
- Route private subnets through it
- Give the partner all EIPs
- For Lambda, place it in the VPC private subnets so egress uses the NAT
- Verify
curl https://checkip.amazonaws.com
Why โ Auto-assigned public IPs change on stop/start, Elastic IPs and NAT EIPs do not.
Interview tip โ Mention you need all AZ EIPs on the allowlist, not just one.
Q40 You must expose an internal service to 200 customer VPCs privately without peering. What do you build?
Intermediate
Situation read โ PrivateLink endpoint service scales to many consumers with no CIDR coordination.
What I'd do โ
- Put the service behind an NLB
- Create the endpoint service and allow principals by account or org
- Enable acceptance if you want control
- Consumers create interface endpoints, optionally with private DNS names verified on your domain
- Monitor
ActiveConnectionsand use cross-zone settings
Why โ Consumers get a local ENI in their subnets, so there is no routing or overlap issue.
Interview tip โ Mention that NLB is required (or GWLB for appliances).
Q41 What is a VPC flow log and how would you use it when a connection is mysteriously dropped?
Beginner
Situation read โ Flow logs record accepted and rejected flows per ENI, subnet or VPC.
What I'd do โ
- Enable:
aws ec2 create-flow-logs --resource-type VPC --resource-ids vpc-0abc --traffic-type ALL --log-destination-type s3 --log-destination arn:aws:s3:::flowlogs-bucket - Query with Athena for
action = 'REJECT'on the destination IP and port - Distinguish SG vs NACL: stateless NACL rejects often show up on return traffic
- Fix the rule that shows the REJECT
Why โ Flow logs show whether traffic reached the ENI and was refused, narrowing blame to the network.
Interview tip โ Flow logs exclude DNS to Route 53 resolver and IMDS traffic.
Q42 The ALB health checks fail only for targets in one subnet. What could differ?
Intermediate
Situation read โ One subnet differs in routing, NACL, or SG source.
What I'd do โ
- Compare NACLs on the failing subnet for the health check port
- Confirm the target SG allows the ALB SG on the health check port
- Confirm the subnet is enabled for the ALB's AZ
- Check the instance's local firewall and app listening address with
ss -ltnp
Why โ Health checks originate from ALB ENIs in the enabled subnets, so subnet-level rules matter.
Interview tip โ Mention app binding to 127.0.0.1 as the classic cause.
Q43 Your company is acquiring another with the same 10.0.0.0/16. How do you integrate networks?
Advanced
Situation read โ Overlap blocks direct routing; options are renumbering, NAT or service-level exposure.
What I'd do โ
- Short term: expose only needed services with PrivateLink
- Or use a private NAT gateway with a non-overlapping translation range via Transit Gateway
- Long term: renumber one side to a new range during migrations, and plan with IPAM
- Adopt Amazon VPC IPAM to prevent new overlaps
Why โ Private NAT lets overlapping networks talk with translated addresses without renumbering first.
Interview tip โ Mention secondary CIDR associations for new workloads.
Q44 How would you secure a VPC against data exfiltration to the internet?
Intermediate
Situation read โ Default-deny egress with allow-listed destinations and visibility.
What I'd do โ
- Remove public IPs, route egress through NAT and AWS Network Firewall using domain-list rules
- Tighten SG egress rules
- Use Route 53 Resolver DNS Firewall to block unknown domains
- Add endpoint policies for S3 to restrict to your buckets
- Alert on GuardDuty exfiltration findings
Why โ DNS and S3 are the typical exfiltration paths, so control both.
Interview tip โ SG default egress allows all; mention that you tighten it.
Q45 What happens when you delete the default VPC and why might you?
Beginner
Situation read โ Default VPCs have public subnets and permissive defaults that bypass your network design.
What I'd do โ
- Delete in every region via CLI, including subnets, IGW and the VPC
- Prevent recreation of workloads in them using an SCP and detect with Config
- If needed,
aws ec2 create-default-vpcrestores it
Why โ Removing it prevents people launching instances into an unmanaged, internet-routable network.
Interview tip โ Mention doing it for all regions, not just the one you use.
Q46 Latency between two regions is high for a replication job. What network options exist?
Intermediate
Situation read โ Public internet paths vary; AWS backbone options offer more consistency.
What I'd do โ
- Use inter-region VPC peering or Transit Gateway peering, which stay on the AWS backbone
- Check throughput limits and use multiple flows because single-flow bandwidth is limited
- For S3 use Cross-Region Replication, for DBs use native replication
- Test with
iperf3across two instances
Why โ Backbone traffic is encrypted and avoids congestion hotspots on the public internet.
Interview tip โ Know that single TCP flow caps at about 5 Gbps within a placement group and less across regions.
Q47 Design DNS for a hybrid environment where on-prem and AWS must resolve each other's private names.
Advanced
Situation read โ Route 53 Resolver endpoints forward in both directions.
What I'd do โ
- Create an inbound endpoint so on-prem DNS can forward
*.aws.internalto it - Create an outbound endpoint and forwarding rule for
corp.example.comto on-prem DNS servers - Share rules via RAM across accounts
- Associate private hosted zones with all VPCs
- Test with
dig @10.0.1.10 db.aws.internalfrom on-prem
Why โ Resolver endpoints bridge the VPC's .2 resolver and external servers without running your own DNS fleet.
Interview tip โ Put endpoints in at least two AZs.
Q48 An EKS cluster ran out of IP addresses in its subnets. What do you do?
Intermediate
Situation read โ The VPC CNI assigns a VPC IP per pod, so small subnets exhaust quickly.
What I'd do โ
- Associate a secondary CIDR such as
100.64.0.0/16with the VPC - Enable custom networking so pods use the new subnets
- Or enable prefix delegation:
kubectl set env daemonset aws-node -n kube-system ENABLE_PREFIX_DELEGATION=true - Long term, size subnets larger from the start
Why โ Secondary CIDRs expand capacity without re-IPing nodes.
Interview tip โ Mention IPv6 EKS clusters avoid the problem entirely.
Q49 How do you restrict an S3 bucket so it is reachable only from your VPC?
Intermediate
Situation read โ Combine a gateway endpoint with a bucket policy condition.
What I'd do โ
- Add a Deny statement with
StringNotEqualsonaws:SourceVpceequal tovpce-0abc - Keep an exception for admin roles or the console flow
- Test from inside and outside the VPC
- Don't lock out CloudFormation or other AWS service principals
Why โ A deny-unless-endpoint policy blocks leaked credentials used from outside.
Interview tip โ Mention the risk of locking out yourself; test with a break-glass role.
Q50 Design a multi-AZ NAT strategy and justify cost versus resilience.
Advanced
Situation read โ One NAT gateway per AZ avoids cross-AZ charges and an AZ-failure blast radius.
What I'd do โ
- Deploy a NAT gateway in each public subnet
- Per-AZ private route tables point to the NAT in the same AZ
- For dev, use one NAT to save about $32 per month per gateway
- Alarm on
ErrorPortAllocationandPacketsDropCount - Use IPv6 or endpoints to reduce the load
Why โ An AZ outage with a single NAT takes all private-subnet egress with it.
Interview tip โ Prod: one per AZ. Non-prod: one shared.
Q51 What is the purpose of an Elastic IP and what is the downside of leaving them unattached?
Beginner
Situation read โ EIP is a static public IPv4 owned by the account.
What I'd do โ
- Allocate:
aws ec2 allocate-address --domain vpc - Associate with an instance or NAT gateway
- List unassociated:
aws ec2 describe-addresses --query 'Addresses[?AssociationId==null]' - Release those you do not need
Why โ Public IPv4 addresses are billed hourly whether or not attached.
Interview tip โ Prefer DNS and load balancers over EIPs for services.
EC2, Auto Scaling and Load Balancing
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q52 Traffic doubles every Friday evening. How do you make the web tier handle it automatically?
Beginner
Situation read โ Predictable spikes call for scheduled scaling plus a reactive policy as a safety net.
What I'd do โ
- Put instances in an Auto Scaling group across at least two AZs behind an ALB
- Add a target tracking policy on
ALBRequestCountPerTargetor CPU at 50 to 60 percent - Add a scheduled action to raise
MinSizeFriday at 16:00 - Use a launch template with a baked AMI so instances are ready in under two minutes
Why โ Scheduled capacity removes cold-start lag, target tracking handles the surprise.
Interview tip โ Mention predictive scaling for repeating patterns.
Q53 What is the difference between an ALB, an NLB and a Gateway Load Balancer?
Beginner
Situation read โ They operate at different layers for different jobs.
What I'd do โ
- ALB is layer 7: host and path routing, redirects, OIDC auth, WebSocket and gRPC
- NLB is layer 4: TCP, UDP, TLS, static IPs per AZ, extreme throughput, PrivateLink backend
- GWLB is layer 3: transparent insertion of firewalls and inspection appliances over GENEVE
- Choose ALB for HTTP microservices, NLB for non-HTTP or fixed IP, GWLB for appliances
Why โ Matching layer to need avoids paying for features you do not use.
Interview tip โ NLB preserves client IP by default for instance targets.
Q54 You deploy a new version to an ASG without downtime. Which approach do you use?
Intermediate
Situation read โ Instance refresh with health-gated batches or blue/green with two target groups.
What I'd do โ
- Update the launch template version
- Start:
aws autoscaling start-instance-refresh --auto-scaling-group-name web --preferences '{"MinHealthyPercentage":90,"InstanceWarmup":120}' - Watch with
describe-instance-refresh - For safer cutovers use a second ASG and weighted ALB target groups, then shift 10, 50, 100 percent
Why โ Refresh replaces instances gradually, honoring health so capacity never drops below the floor.
Interview tip โ Mention checkpoints and auto-rollback preferences.
Q55 Instances in an ASG keep getting terminated and replaced in a loop. What is going on?
Intermediate
Situation read โ Health checks are failing before the app is ready, or user data is crashing.
What I'd do โ
- Look at the activity history:
aws autoscaling describe-scaling-activities --auto-scaling-group-name web - Check cause text such as "Terminating EC2 instance: health check type ELB"
- Increase
HealthCheckGracePeriodbeyond boot plus app start time - Read
/var/log/cloud-init-output.logvia a suspended instance - Use
aws autoscaling suspend-processes --scaling-processes ReplaceUnhealthyto debug
Why โ ELB health checks start immediately after grace period; a slow boot keeps tripping them.
Interview tip โ Suspending ReplaceUnhealthy is the debug trick that proves you have done this.
Q56 You want to save up to 70 percent on a stateless batch fleet. What do you design?
Intermediate
Situation read โ Spot Instances with diversification and interruption handling.
What I'd do โ
- Use an ASG mixed instances policy across 8 to 10 instance types and all AZs with allocation strategy
price-capacity-optimized - Keep a small On-Demand base
- Handle the two-minute interruption notice via EventBridge or IMDS to drain and checkpoint
- Use SQS so work is retried on interruption
- Enable capacity rebalancing
Why โ Diversified pools lower the chance that one capacity pool dries up.
Interview tip โ Never run stateful singletons on Spot.
Q57 Choose between Savings Plans and Reserved Instances for a steady fleet that is changing instance families.
Intermediate
Situation read โ Compute Savings Plans keep flexibility across family, region and even Fargate and Lambda.
What I'd do โ
- Review usage in Cost Explorer Savings Plans recommendations
- Commit to roughly 70 to 80 percent of the steady baseline, not peak
- Choose Compute SP for flexibility, EC2 Instance SP for a higher discount when family is fixed
- Use RIs only for specific cases such as RDS or capacity reservations
- Revisit quarterly
Why โ Over-commitment wastes money; under-commitment leaves discount on the table.
Interview tip โ Savings Plans do not reserve capacity; RIs with zonal scope do.
Q58 A stopped-and-started EC2 instance changed its public IP and broke the DNS record. How do you prevent that?
Beginner
Situation read โ Auto-assigned public IPs are released on stop.
What I'd do โ
- Put a load balancer in front and point DNS at it
- Or associate an Elastic IP
- Or use a Route 53 alias to the ALB
- Avoid pointing DNS at instance IPs
Why โ Load balancer DNS names are stable endpoints that survive instance replacement.
Interview tip โ Treat instances as cattle.
Q59 An ALB returns 502 intermittently during deployments. How do you stop that?
Intermediate
Situation read โ Targets are being deregistered with in-flight requests, or the app closes keep-alive connections early.
What I'd do โ
- Set deregistration delay to match the longest request, such as 30 to 60 seconds
- Make the app handle SIGTERM and finish requests
- Set app keep-alive timeout greater than the ALB idle timeout (60 s default)
- Use slow start for new targets
- Check
HTTPCode_ELB_502_Countand target response time metrics
Why โ A backend closing idle connections sooner than the ALB expects causes 502s on reused connections.
Interview tip โ State the rule: backend keep-alive greater than load balancer idle timeout.
Q60 Design a zero-downtime blue/green for a monolith on EC2 behind an ALB.
Advanced
Situation read โ Two environments, one listener, weighted shift with fast rollback.
What I'd do โ
- Create blue and green ASGs, each with its own target group
- Deploy the new AMI to green and run smoke tests against a test listener on port 8443
- Shift listener weights 10, 50, 100 percent with alarms on 5xx and latency
- Keep blue running for 30 minutes then scale to zero
- Roll back by flipping weights back:
aws elbv2 modify-listener --listener-arn ... --default-actions ...
Why โ Rollback is a weight change, not a redeploy, so recovery takes seconds.
Interview tip โ Mention database migrations must be backward compatible for this to work.
Q61 An EC2 instance is running at 100 percent CPU with CPU credits at zero. What happened?
Intermediate
Situation read โ A burstable T-family instance exhausted its credits and is throttled to baseline.
What I'd do โ
- Confirm
CPUCreditBalancein CloudWatch - Switch to unlimited mode:
aws ec2 modify-instance-credit-specification - Or right-size to M or C family
- Or scale out with an ASG
- Compare costs; unlimited bills surplus credits
Why โ T instances are cheap only for low average CPU; sustained load needs fixed-performance instances.
Interview tip โ Never run steady production CPU on T-class without unlimited.
Q62 Your ASG launched instances in only one AZ and an AZ outage took down the service. Why?
Intermediate
Situation read โ The ASG was configured with a single subnet, or the AZs were imbalanced.
What I'd do โ
- Check
aws autoscaling describe-auto-scaling-groupsforAvailabilityZones - Add subnets across 3 AZs
- Make sure the ALB has those AZs enabled
- Enable AZ rebalancing
- Test with an AZ failure drill using ARC zonal shift
Why โ Multi-AZ is only real if both the ALB and the ASG span it with enough capacity per AZ.
Interview tip โ Mention over-provisioning N+1 across AZs.
Q63 How would you connect to a private EC2 instance for troubleshooting without a bastion?
Beginner
Situation read โ Use Systems Manager Session Manager.
What I'd do โ
- Ensure the instance has
AmazonSSMManagedInstanceCore - Start:
aws ssm start-session --target i-0abc - For port forwarding use
--document-name AWS-StartPortForwardingSession --parameters portNumber=5432,localPortNumber=5432 - Session logs go to S3 or CloudWatch for audit
Why โ No inbound ports, no SSH keys, and every session is audited.
Interview tip โ Mention EC2 Instance Connect Endpoint as another keyless option.
Q64 The business requires 99.99 percent for a customer API. How do you compose EC2 components?
Intermediate
Situation read โ Multi-AZ everything, no single points, and automated recovery.
What I'd do โ
- ALB across three AZs, ASG with min 3
- Stateless instances, state in DynamoDB or Multi-AZ Aurora
- Health checks at ELB level, deep health endpoints
- Route 53 health checks with failover to a second region if needed
- Error budget alarms and game-day tests
Why โ Availability multiplies; each tier must itself be redundant.
Interview tip โ Be honest about regional dependencies like IAM and Route 53 control planes.
Q65 Right-size a fleet of 300 instances where nobody knows actual usage. How?
Advanced
Situation read โ Data-driven right-sizing with guardrails, not guessing.
What I'd do โ
- Enable Compute Optimizer across the org and install CloudWatch agent for memory metrics
- Pull recommendations:
aws compute-optimizer get-ec2-instance-recommendations - Sort by savings and risk, start with over-provisioned dev and staging
- Change one size down at a time and watch p99 latency
- Move to Graviton (m7g, c7g) where the stack supports ARM
Why โ CPU-only data misses memory pressure; the agent metric makes the call accurate.
Interview tip โ Graviton typically gives 20 percent better price-performance.
Q66 User data script ran but the app is not installed. How do you debug a new launch template?
Intermediate
Situation read โ User data runs once at first boot as root through cloud-init, and failures are silent unless you look.
What I'd do โ
- SSM into the instance and read
/var/log/cloud-init-output.log - Run
cloud-init status --long - Check the script has a shebang and
set -euxo pipefail - Verify the instance has outbound access for package repositories
- Fix the template and refresh
Why โ Most user data failures are no network path or a missing shebang.
Interview tip โ Better: bake an AMI with EC2 Image Builder so boot does less.
Q67 What is the difference between an AMI, a snapshot and an instance store?
Beginner
Situation read โ AMI is a template, a snapshot is a block-level backup in S3, instance store is ephemeral local disk.
What I'd do โ
- Create an AMI from an instance:
aws ec2 create-image --instance-id i-0abc --name web-v12 - Snapshots back EBS volumes and are incremental
- Instance store data is lost on stop or termination
- Use it only for caches or scratch
Why โ Knowing which storage persists is basic to not losing data.
Interview tip โ EBS persists after stop; instance store does not.
Q68 Your fleet needs OS patching monthly with no manual SSH. How do you automate it?
Intermediate
Situation read โ Systems Manager Patch Manager with maintenance windows.
What I'd do โ
- Tag instances by
PatchGroup - Create a patch baseline and a maintenance window
- Register the
AWS-RunPatchBaselinetask with rate control (10 percent concurrency, 5 percent error threshold) - Combine with ASG instance refresh to bake new AMIs instead of in-place patching for immutable fleets
- Report compliance in the console
Why โ Immutable AMI rotation beats patching in place for repeatability.
Interview tip โ Mention rate control to avoid patching the whole fleet at once.
Q69 An ALB must route /api to one service and / to another, and also redirect HTTP to HTTPS. How?
Intermediate
/api to one service and / to another, and also redirect HTTP to HTTPS. How?Situation read โ Listener rules handle path routing and redirects natively.
What I'd do โ
- Listener 80: default action redirect to HTTPS 443 with status 301
- Listener 443 with ACM certificate and a rule
path-pattern /api/*forwarding to the api target group - Default action forward to the web target group
- Check rule priority order
aws elbv2 describe-rules --listener-arn ...
Why โ Rules evaluate in priority order, so specific paths must come before the catch-all.
Interview tip โ Mention host-header rules for multi-tenant routing.
Q70 You need zero-downtime AZ failover and a way to rehearse it. What tool do you use?
Advanced
Situation read โ Application Recovery Controller zonal shift moves traffic away from an impaired AZ.
What I'd do โ
- Enable zonal shift on the ALB or NLB
- Run
aws arc-zonal-shift start-zonal-shift --resource-identifier <alb-arn> --away-from eu-west-1a --expires-in 1h --comment drill - Watch capacity and latency in the other AZs
- Pre-scale so remaining AZs can absorb the load
- Practice quarterly
Why โ Shifting traffic is reversible and quick, and rehearsal exposes under-provisioned AZs.
Interview tip โ Static stability: do not depend on control plane actions during a failure.
Q71 An EC2 instance cannot be launched with "InsufficientInstanceCapacity". What are your options?
Intermediate
Situation read โ The AZ is out of that instance type right now.
What I'd do โ
- Retry in another AZ or subnet
- Use a different instance type or size, or
price-capacity-optimizedflexibility - For critical capacity use On-Demand Capacity Reservations
- Use attribute-based instance type selection in the ASG
- Don't hardcode one type
Why โ Flexibility across types and AZs is the best protection against capacity errors.
Interview tip โ Reserve capacity ahead of events like a launch.
Q72 Choose between EBS volume types for a database needing 10,000 IOPS consistently.
Intermediate
Situation read โ gp3 for most; io2 when sustained high IOPS and durability matter.
What I'd do โ
- gp3 lets you provision IOPS (up to 16,000) and throughput independent of size
- io2 Block Express goes to 256,000 IOPS with 99.999 percent durability
- Check the instance limit too, since EBS-optimized bandwidth caps
- Modify live:
aws ec2 modify-volume --volume-id vol-0abc --volume-type gp3 --iops 10000
Why โ gp3 is about 20 percent cheaper than gp2 and decouples performance from size.
Interview tip โ Mention instance-level EBS throughput as a hidden cap.
Q73 Design a self-healing stateful service on EC2, such as a leader-based cluster, with EBS volumes.
Advanced
Situation read โ EBS is AZ-bound, so replacement logic must re-attach or rebuild in the same AZ.
What I'd do โ
- One ASG per AZ with min and max 1, or lifecycle hooks that attach the volume
- Tag volumes and attach with a user data script using the instance's AZ
- Prefer replicated data (rebuild from peers) over reattachment
- Use EBS snapshots through Data Lifecycle Manager
- Alarm on replication lag
Why โ Rebuild-from-peer avoids long reattach waits and corruption risk from forced detach.
Interview tip โ If possible, push state to a managed service.
Q74 What is a placement group and when would you use one?
Beginner
Situation read โ Placement groups control how instances are placed on hardware.
What I'd do โ
- Cluster: low latency, high throughput, one AZ (HPC, tightly coupled)
- Spread: each instance on distinct hardware, max 7 per AZ, for critical small groups
- Partition: groups of instances on distinct racks, for Kafka, Cassandra
- Create:
aws ec2 create-placement-group --group-name hpc --strategy cluster
Why โ The strategy trades off latency against blast-radius.
Interview tip โ Cluster is a single-AZ risk.
Q75 Pick the target type for an ALB serving Lambda, instances and IPs in the same system.
Intermediate
Situation read โ Target groups can be instance, IP or Lambda type.
What I'd do โ
- Instance for ASG-managed hosts
- IP for containers on awsvpc networking, peered or on-prem addresses
- Lambda for serverless endpoints, invoked synchronously
- Weighted forwarding lets you migrate gradually between types
Why โ One ALB can front mixed backends during migrations.
Interview tip โ ECS with awsvpc must use IP targets.
S3, RDS and DynamoDB
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q76 You need to host a static website with HTTPS and low latency worldwide. Which services do you use?
Beginner
Situation read โ S3 as private origin, CloudFront as the public face.
What I'd do โ
- Create a private bucket, no static website hosting endpoint required
- Create a CloudFront distribution with Origin Access Control to the bucket
- Attach an ACM certificate from us-east-1 and add the domain as alternate name
- Route 53 alias record to the distribution
- Default root object
index.html, plus custom error response for SPA routes
Why โ OAC keeps the bucket private so content is only reachable through the CDN.
Interview tip โ Note OAC replaced the older Origin Access Identity.
Q77 Uploaded files in your bucket must be deleted after 90 days and old versions after 30. How do you do that?
Beginner
Situation read โ S3 lifecycle rules.
What I'd do โ
- Enable versioning
- Add a rule: expire current objects after 90 days,
NoncurrentVersionExpiration30 days, and abort incomplete multipart uploads after 7 days - Apply:
aws s3api put-bucket-lifecycle-configuration --bucket app-uploads --lifecycle-configuration file://lifecycle.json - Verify with
get-bucket-lifecycle-configuration
Why โ Lifecycle is free automation that stops storage costs creeping up.
Interview tip โ Mention incomplete multipart uploads as hidden cost.
Q78 Someone deleted objects from a versioned bucket. How do you recover and prevent repeats?
Intermediate
Situation read โ With versioning on, a delete adds a delete marker; the data is still there.
What I'd do โ
- List versions:
aws s3api list-object-versions --bucket b --prefix path/ - Remove the delete marker:
aws s3api delete-object --bucket b --key path/file --version-id <marker-id> - Turn on MFA delete or Object Lock for critical data
- Add a bucket policy denying
s3:DeleteObjectVersionto most principals - Consider replication to a second account
Why โ Deleting the marker restores the previous version instantly.
Interview tip โ Without versioning, deletion is permanent; ask whether it was enabled.
Q79 Millions of small objects are being uploaded and S3 returns 503 Slow Down. What do you do?
Intermediate
Situation read โ Per-prefix request rates (3,500 PUT and 5,500 GET per second) were exceeded.
What I'd do โ
- Spread keys across multiple prefixes
- Add retries with exponential backoff and jitter in the SDK
- Batch small objects into larger ones
- Request-rate scale-up is automatic over minutes, so ramp traffic gradually
- Check CloudWatch
5xxErrorsrequest metrics
Why โ S3 scales per prefix, so more prefixes means more throughput.
Interview tip โ Backoff plus jitter is the universal AWS client answer.
Q80 Large 50 GB files upload slowly from remote offices to S3. How do you speed it up?
Intermediate
Situation read โ Use multipart parallel uploads and edge acceleration.
What I'd do โ
- Multipart is automatic in the CLI: tune
aws configure set default.s3.multipart_chunksize 64MBandmax_concurrent_requests 20 - Enable Transfer Acceleration:
aws s3api put-bucket-accelerate-configuration --bucket b --accelerate-configuration Status=Enabled - Use the accelerate endpoint
b.s3-accelerate.amazonaws.com - For bulk offline use Snowball
Why โ Parallel parts use multiple connections, and acceleration shortens the public hop via edge locations.
Interview tip โ Acceleration has per-GB cost; test with the speed comparison tool first.
Q81 Design a cross-region DR strategy for a critical S3 bucket with a 15-minute RPO.
Advanced
Situation read โ S3 Replication Time Control is the only option with an SLA on replication time.
What I'd do โ
- Enable versioning on both buckets
- Configure CRR with S3 RTC (99.99 percent of objects within 15 minutes)
- Replicate delete markers if desired and KMS-encrypted objects with the destination key
- Monitor
ReplicationLatencyand failed replication events - Use Multi-Region Access Points for failover routing
Why โ Normal replication is best-effort, RTC makes it contractual and monitorable.
Interview tip โ Mention replication does not cover pre-existing objects without batch replication.
Q82 An analytics team needs query access to 10 TB of logs in S3 without loading a warehouse. What do you propose?
Intermediate
Situation read โ Athena over partitioned columnar data.
What I'd do โ
- Convert JSON logs to Parquet with Glue or Athena CTAS
- Partition by
year/month/dayand use Glue Data Catalog - Use partition projection to avoid crawlers
- Query:
SELECT count(*) FROM logs WHERE dt = '2026-11-01' - Control cost with workgroup data-scanned limits
Why โ Athena charges per TB scanned, so columnar format and partitions cut cost by 90 percent or more.
Interview tip โ Always mention Parquet plus partitioning.
Q83 Choose between RDS and running a database on EC2.
Beginner
Situation read โ RDS manages backups, patching and failover; EC2 gives control at the cost of operations.
What I'd do โ
- Use RDS or Aurora unless you need unsupported extensions or OS access
- Enable Multi-AZ for production
- Automated backups with a 7 to 35 day retention
- Use parameter groups instead of editing files
- Go EC2 only with a specific need and a team to run it
Why โ Operational toil is the real cost of self-managed databases.
Interview tip โ RDS Custom exists for the in-between case.
Q84 Your RDS primary failed over to the standby. What happened and what must the app do?
Intermediate
Situation read โ In Multi-AZ, RDS flips the DNS endpoint CNAME to the standby, usually in 60 to 120 seconds.
What I'd do โ
- App must reconnect: use the endpoint DNS name, never an IP
- Set low DNS TTL awareness and connection retry
- Check events:
aws rds describe-events --source-type db-instance --source-identifier mydb - Test failover:
aws rds reboot-db-instance --db-instance-identifier mydb --force-failover - Use RDS Proxy to keep connections stable
Why โ The standby is synchronously replicated, so no data is lost but connections drop.
Interview tip โ Multi-AZ is for HA, not for read scaling (except the Multi-AZ cluster option).
Q85 The database CPU is high due to read traffic. How do you scale reads?
Intermediate
Situation read โ Offload reads to replicas and cache.
What I'd do โ
- Create read replicas:
aws rds create-db-instance-read-replica --db-instance-identifier mydb-r1 --source-db-instance-identifier mydb - Route read queries with a reader endpoint (Aurora) or app-level routing
- Add ElastiCache for hot keys
- Check slow queries with Performance Insights
- Watch
ReplicaLag
Why โ Replicas are asynchronous, so reads can be stale; choose consistency needs deliberately.
Interview tip โ Fix bad queries before adding hardware.
Q86 Plan a major-version RDS PostgreSQL upgrade with minimal downtime.
Advanced
Situation read โ Blue/green deployments make a staged copy that you switch over.
What I'd do โ
- Create:
aws rds create-blue-green-deployment --blue-green-deployment-name pg-upgrade --source <arn> --target-engine-version 17.2 - Test the green environment with real queries and extension checks
- Pause writes or accept a brief switchover, then
switchover-blue-green-deployment - Keep blue for rollback until verified
- Run
ANALYZEafter upgrade
Why โ Switchover typically takes under a minute and avoids in-place upgrade risk.
Interview tip โ Mention testing extensions and parameter compatibility first.
Q87 Lambda functions exhaust database connections on RDS under load. Fix it.
Intermediate
Situation read โ Each concurrent Lambda opens its own connection.
What I'd do โ
- Put RDS Proxy in front and connect to the proxy endpoint
- Create it with a Secrets Manager secret and the DB SG
- Reuse connections outside the handler
- Limit reserved concurrency
- Monitor
DatabaseConnections
Why โ The proxy pools and multiplexes connections so bursts do not hit max_connections.
Interview tip โ Proxy needs IAM auth or secrets and runs in the VPC.
Q88 DynamoDB throws ProvisionedThroughputExceededException for one user's activity. Why, and what's the fix?
Intermediate
Situation read โ A hot partition: one partition key takes disproportionate traffic.
What I'd do โ
- Look at CloudWatch Contributor Insights for the hot key
- Redesign the key to spread load, such as adding a shard suffix
user#17 - Switch to on-demand mode if the pattern is unpredictable
- Add DAX for read-heavy hotspots
- Add SDK backoff
Why โ Throughput is divided among partitions, so even keys matter more than total capacity.
Interview tip โ Adaptive capacity helps but does not fix a skewed design.
Q89 When do you choose DynamoDB over RDS?
Intermediate
Situation read โ Known access patterns, massive scale, single-digit-millisecond latency, little ops.
What I'd do โ
- Use DynamoDB for key-value or single-table designs like sessions, carts, IoT
- Use RDS or Aurora for relational joins, ad hoc queries and transactions across entities
- Model DynamoDB around queries, using GSIs for alternate access
- Prove the access patterns before committing
Why โ DynamoDB is hard to retrofit with new query patterns, so choose it on certainty.
Interview tip โ Say "access patterns first".
Q90 Design a globally available DynamoDB application with active-active writes.
Advanced
Situation read โ Global tables replicate across regions with last-writer-wins conflict resolution.
What I'd do โ
- Create the table with streams and add replicas:
aws dynamodb update-table --table-name orders --replica-updates 'Create={RegionName=eu-west-1}' - Route users with Route 53 latency routing
- Design writes to avoid conflicts, such as region-owned items
- Monitor
ReplicationLatency - Use multi-Region strong consistency option only when needed
Why โ Replication is asynchronous and conflicts resolve by timestamp, so data modeling prevents lost updates.
Interview tip โ Mention idempotent writes.
Q91 You must restore a DynamoDB table to 14:30 yesterday. How?
Intermediate
Situation read โ Point-in-time recovery restores to a new table.
What I'd do โ
- Make sure PITR is enabled:
aws dynamodb update-continuous-backups --table-name t --point-in-time-recovery-specification PointInTimeRecoveryEnabled=true - Restore:
aws dynamodb restore-table-to-point-in-time --source-table-name t --target-table-name t-restore --restore-date-time 2026-11-08T14:30:00Z - Copy indexes, TTL, alarms and IAM manually
- Swap application to the new table
Why โ PITR keeps 35 days of continuous backups and restores never overwrite in place.
Interview tip โ Remember PITR is off by default.
Q92 The RDS storage is 95 percent full on a Friday. What is the safe response?
Intermediate
Situation read โ Storage autoscaling or manual modify can extend online.
What I'd do โ
- Modify:
aws rds modify-db-instance --db-instance-identifier mydb --allocated-storage 500 --apply-immediately - Enable storage autoscaling with
--max-allocated-storage 2000 - Find bloat or giant logs and purge
- Note the six-hour cooldown between modifications
- Alert on
FreeStorageSpaceat 20 percent
Why โ Storage can grow online but never shrink, so size growth with intent.
Interview tip โ Mention the cooldown trap.
Q93 Aurora versus RDS PostgreSQL: how do you decide?
Advanced
Situation read โ Aurora gives faster failover, shared storage and up to 15 replicas, at a higher price.
What I'd do โ
- Pick Aurora for heavy read scale, quick failover (about 30 seconds), serverless v2 elasticity or global database
- Pick RDS PostgreSQL for cost and plain engine behavior
- Compare IOPS charges against Aurora I/O-Optimized
- Benchmark with production-like load
Why โ Aurora decouples compute and storage, replicas read the same volume with tiny lag.
Interview tip โ Don't claim Aurora is always better; cost matters.
Q94 An S3 bucket receiving PUTs must trigger processing for each file. What is the design?
Intermediate
Situation read โ S3 event notifications to SQS or EventBridge, then workers.
What I'd do โ
- Configure notifications on
s3:ObjectCreated:*to an SQS queue - Lambda or ECS workers poll the queue
- Add a DLQ with
maxReceiveCount5 - Use EventBridge instead for multiple consumers and filtering
- Make processing idempotent since events are at-least-once
Why โ A queue buffers bursts and decouples upload rate from processing rate.
Interview tip โ S3 to Lambda directly is fine for small flows but lacks buffering.
Q95 Share a private S3 object with an external customer for one hour. How?
Intermediate
Situation read โ Use a presigned URL.
What I'd do โ
- Generate:
aws s3 presign s3://bucket/report.pdf --expires-in 3600 - Sign with a role whose credentials outlive the URL (role session expiry caps URL life)
- For uploads use a presigned PUT or POST policy with size limits
- Log access with S3 server access logs or CloudTrail data events
Why โ The URL carries the signer's permissions temporarily without making the object public.
Interview tip โ URLs signed with temporary credentials die when those credentials expire.
Q96 Design a backup strategy across accounts for RDS, EBS and DynamoDB with ransomware protection.
Advanced
Situation read โ Centralized, immutable, cross-account backups.
What I'd do โ
- Use AWS Backup with a backup plan and tag-based selection
- Copy to a vault in a separate backup account and region
- Enable Backup Vault Lock in compliance mode for immutability
- Restrict vault access policy
- Run restore tests regularly
Why โ An attacker with workload-account admin cannot delete locked copies in another account.
Interview tip โ Untested backups are a hope, not a plan.
Q97 The application writes and then immediately reads from S3 and sometimes gets stale data. Is that possible?
Intermediate
Situation read โ S3 has been strongly consistent for reads after writes since December 2020.
What I'd do โ
- Check whether reads pass through CloudFront cache
- Check replication destinations, which are eventual
- Check app-level caching
- Verify with
aws s3api head-objectright after the PUT
Why โ The staleness almost always comes from a layer above S3.
Interview tip โ If someone says S3 is eventually consistent, correct them politely.
Q98 How do you encrypt data at rest in S3 and who manages the keys?
Beginner
Situation read โ SSE-S3 by default; SSE-KMS gives key-level audit and control.
What I'd do โ
- Default encryption SSE-S3 applies to new objects automatically
- For regulated data set SSE-KMS with a customer managed key
- Enable S3 Bucket Keys to cut KMS request cost
- Use
aws s3api put-bucket-encryption - Grant
kms:Decryptto consumers
Why โ KMS adds an audit trail and revocable key access.
Interview tip โ SSE-C and client-side encryption exist but add key handling burden.
Q99 Plan a migration of a 5 TB on-prem Oracle database to AWS with minimal downtime.
Advanced
Situation read โ DMS with ongoing replication after schema conversion.
What I'd do โ
- Assess with Schema Conversion Tool and decide target (RDS Oracle, or Aurora PostgreSQL if converting)
- Create the target, load schema, then start a DMS task with full load plus CDC
- Validate rows with DMS data validation
- Cut over: stop writes, wait for lag zero, repoint the app
- Keep reverse replication for rollback
Why โ CDC keeps the target within seconds of the source so cutover is minutes.
Interview tip โ Mention a network path (DX or VPN) sized for the initial load.
Route 53, CloudFront and Messaging
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q100 You want users routed to the nearest healthy region. Which Route 53 policy do you use?
Beginner
Situation read โ Latency routing with health checks.
What I'd do โ
- Create latency records for
api.example.comin eu-west-1 and us-east-1 - Attach Route 53 health checks to each
- Use alias records to the regional ALBs with
EvaluateTargetHealthtrue - Test:
dig api.example.comfrom different locations - Keep TTL low, 60 seconds
Why โ Latency routing picks the lowest-latency region, health checks remove failed ones.
Interview tip โ Latency is measured to AWS regions, not to the user's exact location.
Q101 Primary region fails; how do you fail over DNS in a controlled way?
Intermediate
Situation read โ Failover routing with a primary and secondary record.
What I'd do โ
- Primary record with a health check on a deep endpoint
/healthz - Secondary record pointing to the DR region
- Alias with evaluate target health
- For explicit control use Application Recovery Controller routing controls
- Remember clients cache DNS beyond TTL
Why โ Health-checked failover is automatic; ARC gives a manual, safe switch that avoids flapping.
Interview tip โ DNS failover is never instant; mention TTL and resolver caching.
Q102 What is the difference between a CNAME and an alias record in Route 53?
Beginner
Situation read โ Alias is a Route 53 extension that works at the zone apex and is free for AWS targets.
What I'd do โ
- CNAME cannot exist at
example.comapex - Alias to ALB, CloudFront, S3 website, API Gateway, with no query charge
- Alias records resolve to A or AAAA, so health tracking is built in
- Create via
aws route53 change-resource-record-sets
Why โ Alias gives apex support and removes an extra DNS hop.
Interview tip โ Use alias for AWS resources, CNAME for external ones.
Q103 Roll out a new version to 5 percent of users using DNS. How?
Intermediate
Situation read โ Weighted routing.
What I'd do โ
- Create two records with weights 95 and 5 and different
SetIdentifier - Attach health checks
- Increase weight over time
- Monitor errors per version
- Prefer ALB weighted target groups for finer control because DNS caching blurs percentages
Why โ DNS weights are probabilities per resolver query, not per user.
Interview tip โ Say DNS canaries are coarse; ALB or CloudFront continuous deployment is better.
Q104 CloudFront serves stale content after you deployed a new JS bundle. How do you handle cache correctly?
Intermediate
Situation read โ Hash filenames for assets and invalidate only the entry HTML.
What I'd do โ
- Build with content hashes like
app.3f9a1c.jsand long TTLCache-Control: max-age=31536000, immutable - Keep
index.htmlat short TTL - Invalidate:
aws cloudfront create-invalidation --distribution-id E123 --paths /index.html - Use a cache policy rather than legacy settings
Why โ Versioned filenames avoid invalidations, which are slow and cost beyond the free quota.
Interview tip โ Mention first 1,000 paths per month are free.
Q105 CloudFront returns 403 from an S3 origin. List the checks.
Intermediate
Situation read โ It's usually OAC or bucket policy, or a missing object.
What I'd do โ
- Verify the bucket policy allows
cloudfront.amazonaws.comwithAWS:SourceArnequal to the distribution ARN - Check the origin uses OAC and the correct bucket regional domain
- Check the object key exists, since missing keys return 403 without
s3:ListBucket - Check SSE-KMS key policy allows CloudFront
- Inspect with
curl -I https://d111.cloudfront.net/index.html
Why โ S3 hides existence of keys from principals lacking list permission, producing 403 instead of 404.
Interview tip โ KMS-encrypted origins need extra OAC key policy.
Q106 Protect an origin so that only CloudFront can reach your ALB.
Advanced
Situation read โ Use the managed prefix list and a secret header.
What I'd do โ
- In the ALB SG allow 443 from the
com.amazonaws.global.cloudfront.origin-facingprefix list - Have CloudFront add a custom header
X-Origin-Verify: <secret> - ALB listener rule forwards only when the header matches, else 403
- Rotate the secret with Secrets Manager
- Or use VPC origins for private ALBs
Why โ The prefix list stops direct IP access, the header stops other CloudFront distributions.
Interview tip โ VPC origins removes the public ALB entirely.
Q107 Add WAF protection against SQL injection and bot floods for a public app.
Intermediate
Situation read โ AWS WAF on CloudFront or ALB with managed rule groups and rate limits.
What I'd do โ
- Create a web ACL with AWS managed rules
AWSManagedRulesCommonRuleSetandAWSManagedRulesSQLiRuleSet - Add a rate-based rule such as 2,000 requests per 5 minutes per IP
- Start in Count mode, review logs, then Block
- Send logs to S3 or CloudWatch
- Add Shield Advanced for DDoS needs
Why โ Count mode prevents false positives from blocking real customers on day one.
Interview tip โ Mention WAF logging to inspect matches.
Q108 A queue consumer crashes mid-message and the message is processed twice. Is that a bug?
Beginner
Situation read โ SQS standard is at-least-once, so duplicates are expected.
What I'd do โ
- Make consumers idempotent using a dedupe key in DynamoDB with a conditional write
- Tune
VisibilityTimeoutabove processing time - Use FIFO with
MessageDeduplicationIdif ordering and dedupe are needed - Configure a DLQ
- Delete only after success:
aws sqs delete-message
Why โ Visibility timeout hides the message during processing, crashes make it reappear.
Interview tip โ Idempotency is the answer to every at-least-once system.
Q109 Messages keep failing and blocking others in a queue. How do you isolate poison messages?
Intermediate
Situation read โ Use a dead-letter queue with a redrive path.
What I'd do โ
- Set
RedrivePolicywithmaxReceiveCount5 to a DLQ - Alarm on
ApproximateNumberOfMessagesVisibleon the DLQ - Inspect messages, fix the bug, then redrive:
aws sqs start-message-move-task --source-arn <dlq-arn> - Keep DLQ retention longer than main (14 days)
Why โ DLQ keeps healthy flow moving and preserves bad messages for diagnosis.
Interview tip โ Mention FIFO message group blocking.
Q110 One event must fan out to email, an SQS worker and a Lambda. What do you use?
Intermediate
Situation read โ SNS topic with multiple subscriptions.
What I'd do โ
- Create the topic and subscribe email, SQS queue and Lambda
- Allow SNS to send to the queue via the queue policy
- Add subscription filter policies by message attribute
- Enable raw message delivery to SQS
- Use FIFO topics if ordering matters
Why โ Pub/sub decouples publisher from consumers, so adding one needs no publisher change.
Interview tip โ Filter policies cut cost by delivering only relevant messages.
Q111 Choose between SQS, SNS, EventBridge and Kinesis for an order platform.
Intermediate
Situation read โ They suit different delivery shapes.
What I'd do โ
- SQS: buffering and work queues, one consumer group
- SNS: simple high-throughput fan-out
- EventBridge: content-based routing, schema registry, SaaS and cross-account events
- Kinesis or MSK: ordered high-volume streams with replay
- Combine, such as EventBridge to SQS for durable consumers
Why โ Choose by routing needs and replay requirement.
Interview tip โ Replay and ordering point to streams, not queues.
Q112 You need a nightly job that runs at 02:00 UTC and triggers an ECS task. How?
Intermediate
Situation read โ EventBridge Scheduler is the managed cron.
What I'd do โ
- Create the schedule:
aws scheduler create-schedule --name nightly --schedule-expression "cron(0 2 * * ? *)" --target '{"Arn":"<cluster-arn>","RoleArn":"<role>","EcsParameters":{...}}' --flexible-time-window Mode=OFF - Give the role
ecs:RunTaskandiam:PassRole - Add retry and a DLQ
- Alarm on failure
Why โ No server to maintain, and time zones and retries are supported.
Interview tip โ Mention iam:PassRole as the usual gotcha.
Q113 Design an event-driven order pipeline that is resilient to downstream outage.
Advanced
Situation read โ Durable buffering between each stage.
What I'd do โ
- API Gateway to Lambda writes the order to DynamoDB and emits an event to EventBridge
- EventBridge rules route to SQS queues per consumer (billing, inventory, email)
- Consumers read with batch size and partial batch failure response
- DLQs and alarms on age of oldest message
- Use outbox pattern with DynamoDB Streams for exactly-recorded publishing
Why โ Queues absorb outages, so a billing downtime delays but never loses orders.
Interview tip โ Mention ApproximateAgeOfOldestMessage as the best queue health alarm.
Q114 Lambda reading SQS processes the same failed batch repeatedly. How to fix partial failures?
Intermediate
Situation read โ Without partial batch response, one bad record retries the whole batch.
What I'd do โ
- Enable
ReportBatchItemFailureson the event source mapping - Return
{"batchItemFailures":[{"itemIdentifier":"<messageId>"}]} - Set a DLQ on the queue
- Set visibility timeout at least 6 times function timeout
- Reduce batch size if poison messages are common
Why โ Only failed records return to the queue.
Interview tip โ AWS recommends 6x function timeout for visibility.
Q115 How do you make a Route 53 private hosted zone resolve names inside two VPCs?
Beginner
Situation read โ Associate the zone with each VPC.
What I'd do โ
aws route53 associate-vpc-with-hosted-zone --hosted-zone-id Z123 --vpc VPCRegion=eu-west-1,VPCId=vpc-0abc- For cross-account use
create-vpc-association-authorizationfirst - Enable
enableDnsSupportandenableDnsHostnameson the VPC - Test with
digfrom an instance
Why โ PHZ answers only for associated VPCs, so scope is controlled.
Interview tip โ Mention split-horizon DNS using the same zone name public and private.
Q116 Your website domain must serve both example.com and www.example.com over HTTPS via CloudFront. What do you configure?
Intermediate
example.com and www.example.com over HTTPS via CloudFront. What do you configure?Situation read โ Both names as alternate domain names with a matching cert.
What I'd do โ
- Request ACM cert in us-east-1 for both names, validate by DNS
- Add CNAMEs in the distribution
- Route 53 alias A and AAAA records for both
- Redirect www to apex with a CloudFront Function
- Use TLS 1.2 minimum policy
Why โ CloudFront can only use ACM certificates from us-east-1.
Interview tip โ Don't forget AAAA records for IPv6.
Q117 Reduce latency and origin load for a dynamic API globally.
Advanced
Situation read โ Cache what is safe, and use CloudFront as a global network accelerator even for uncacheable calls.
What I'd do โ
- Define cache policies per path: short TTL for GETs, no cache for POST
- Add Origin Shield in the region closest to the origin
- Use persistent connections to origin and HTTP/3 to clients
- Compress with Brotli
- Consider Global Accelerator for non-HTTP or static IP needs
Why โ Edge termination of TLS cuts handshake latency even without cache hits.
Interview tip โ Cache key design is where most wins and bugs live.
Q118 A signed-URL protected video is playable by anyone with the link. How do you restrict it more?
Intermediate
Situation read โ Use CloudFront signed cookies or URLs with short expiry and IP or policy limits.
What I'd do โ
- Create a key group with public key, trusted key groups on the behavior
- Generate a signed URL with custom policy including expiry and IP range
- Keep expiry minutes for streaming sessions through cookies
- Add geo restriction if needed
- Rotate keys through a new key group
Why โ Time-limited signatures minimize reuse of leaked links.
Interview tip โ Use key groups, not the deprecated root account key pairs.
Q119 An SNS to HTTP endpoint subscription does not get messages. What do you check?
Intermediate
Situation read โ Confirmation or delivery failure.
What I'd do โ
- Check the subscription is confirmed (not
PendingConfirmation) - Endpoint must respond 2xx quickly and be reachable publicly over HTTPS
- Review delivery status logs in CloudWatch
- Set a redrive DLQ on the subscription
- Check filter policy not excluding the message
Why โ SNS only retries according to a delivery policy then drops without a DLQ.
Interview tip โ Subscription-level DLQ is essential.
Q120 What is the purpose of Route 53 health checks and what can they monitor?
Beginner
Situation read โ They probe endpoints and drive DNS failover.
What I'd do โ
- HTTP, HTTPS, TCP checks from global checkers
- Calculated health checks combining others
- CloudWatch alarm health checks for private resources
- Alarm via SNS on
HealthCheckStatus
Why โ They let DNS remove failed endpoints automatically.
Interview tip โ Private endpoints need a CloudWatch alarm-based check.
Q121 Design API ingress for 10,000 requests per second with throttling and auth.
Advanced
Situation read โ API Gateway or ALB depending on features and cost.
What I'd do โ
- REST or HTTP API Gateway with Cognito or JWT authorizer, usage plans and throttling
- For high steady volume compare cost with ALB plus Lambda or ECS
- Add WAF
- Default quota is 10,000 rps per region; request increases early
- Add caching and per-client throttling keys
Why โ API Gateway per-request pricing makes ALB cheaper at sustained high traffic.
Interview tip โ Mention HTTP API is cheaper than REST API when features suffice.
Q122 An EventBridge rule is not triggering a target. Quick checklist.
Intermediate
Situation read โ Pattern mismatch or target permission.
What I'd do โ
- Check the event bus is the right one (default vs custom)
- Test the pattern with
aws events test-event-pattern - Check target resource policy or role
- View
FailedInvocationsandInvocationsmetrics - Add a DLQ to the target
Why โ Most issues are pattern typos or missing invoke permissions.
Interview tip โ Use TestEventPattern before deploying.
Q123 Build a DNS-based blue/green cutover for an internal service with rollback.
Intermediate
Situation read โ Weighted alias records plus low TTL.
What I'd do โ
- Lower TTL to 30 seconds a day before
- Add green record weight 0, test via direct name
- Shift 10 percent, 50 percent, 100 percent
- Keep blue for rollback
- Restore TTL after
Why โ Lowering TTL ahead of time is what makes rollback quick.
Interview tip โ Plan TTL changes early.
Q124 How do you stop a public SNS topic or SQS queue from accepting messages from anyone?
Beginner
Situation read โ Resource policies must restrict principals.
What I'd do โ
- Review queue policy
Principaland addaws:SourceArnconditions - Remove
"Principal":"*"unless conditioned - Use IAM Access Analyzer to find external access
- Enable encryption with KMS
Why โ Open resource policies are a common data leak vector.
Interview tip โ Mention Access Analyzer for external findings.
ECS, EKS, Lambda and ECR
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q125 ECS on Fargate or on EC2: how do you choose?
Beginner
Situation read โ Fargate removes host management; EC2 gives control and cost optimization at scale.
What I'd do โ
- Choose Fargate for most services, bursty workloads and small teams
- Choose EC2 for GPUs, large steady fleets with Savings Plans, privileged containers or daemon sets
- Use capacity providers to mix both
- Compare per vCPU-hour cost
Why โ Fargate trades roughly 20 to 30 percent premium for no patching.
Interview tip โ Say "Fargate by default, EC2 when numbers justify".
Q126 Deploy a containerized API on ECS behind an ALB. What are the building blocks?
Beginner
Situation read โ Task definition, service, target group, ALB.
What I'd do โ
- Push the image to ECR
- Register the task definition with
awsvpcnetwork mode, CPU and memory, log driverawslogs, and task role - Create a service with desired count 3 across subnets and attach it to the ALB target group (IP type)
- Configure health check path and deployment circuit breaker
aws ecs update-service --cluster prod --service api --force-new-deployment
Why โ The task role grants app permissions, the execution role lets ECS pull images and write logs.
Interview tip โ Know task role versus execution role.
Q127 An ECS service deployment is stuck, tasks start and stop repeatedly. How do you debug?
Intermediate
Situation read โ The task fails health checks or crashes.
What I'd do โ
aws ecs describe-servicesand read the eventsaws ecs describe-tasks --tasks <arn>forstoppedReasonand exit code- Check CloudWatch logs of the container
- Verify the health check path and grace period
healthCheckGracePeriodSeconds - Enable the deployment circuit breaker with rollback
Why โ The stopped reason usually names OOM (exit 137) or image pull errors directly.
Interview tip โ Exit code 137 equals OOM kill.
Q128 Roll out a new ECS service version with canary and automatic rollback.
Intermediate
Situation read โ Use CodeDeploy blue/green or ECS native blue/green.
What I'd do โ
- Two target groups on the ALB
- Deployment config
CodeDeployDefault.ECSCanary10Percent5Minutes - CloudWatch alarms on 5xx and latency attached to the deployment group
- Automatic rollback on alarm
- Test listener for pre-traffic validation hooks
Why โ Alarms trigger automatic reversal without a human.
Interview tip โ Mention ECS native blue/green as the newer path.
Q129 EKS pods need access to S3 without node-level permissions. How?
Intermediate
Situation read โ IAM roles for service accounts or EKS Pod Identity.
What I'd do โ
- With Pod Identity: install the agent add-on, then
aws eks create-pod-identity-association --cluster-name prod --namespace app --service-account s3-reader --role-arn arn:aws:iam::111111111111:role/s3-reader - Annotate nothing, pods use the SDK default chain
- Role trusts
pods.eks.amazonaws.com - Verify with
aws sts get-caller-identityinside the pod
Why โ Per-pod roles enforce least privilege instead of every pod inheriting the node role.
Interview tip โ IRSA still works; Pod Identity is simpler across clusters.
Q130 Upgrade an EKS cluster from 1.31 to 1.33 safely.
Intermediate
Situation read โ Only one minor version at a time, control plane first.
What I'd do โ
- Check deprecated APIs with
kubentorpluto - Update add-ons compatibility
- Upgrade control plane:
aws eks update-cluster-version --name prod --kubernetes-version 1.32 - Upgrade managed node groups with surge settings
- Repeat for 1.33
- Verify PDBs exist to avoid outages during drains
Why โ Skipping versions is unsupported and API removals cause hard failures.
Interview tip โ Mention the extended support cost for old versions.
Q131 Design node scaling for EKS with mixed Spot and On-Demand and fast scale-up.
Advanced
Situation read โ Karpenter replaces fixed node groups with just-in-time right-sized nodes.
What I'd do โ
- Install Karpenter with a
NodePoolallowing multiple instance families andspotpluson-demandcapacity types - Set
disruptionconsolidation policyWhenEmptyOrUnderutilized - Keep a small managed node group for system pods
- Use PDBs and
topologySpreadConstraints - Handle interruption via SQS queue integration
Why โ Karpenter picks the cheapest fitting instance in seconds rather than scaling fixed groups.
Interview tip โ Mention bin-packing and consolidation.
Q132 An EKS pod is stuck in Pending with "0/3 nodes are available: Insufficient cpu". What do you do?
Intermediate
Situation read โ Capacity or requests are too high.
What I'd do โ
kubectl describe podfor the scheduler messagekubectl top nodesand review requests versus usage- Scale the node group or let the autoscaler add nodes
- Right-size over-large requests
- Check taints and affinity
Why โ Scheduling uses requests, not actual usage.
Interview tip โ Requests drive bin-packing and cost.
Q133 Lambda function times out after 3 seconds calling an external API. What's wrong?
Beginner
Situation read โ Default timeout is 3 seconds, or the function is in a VPC without egress.
What I'd do โ
- Increase timeout:
aws lambda update-function-configuration --function-name f --timeout 30 - If VPC-attached, ensure NAT or endpoint access
- Check logs for the exact duration with REPORT lines
- Set client timeouts shorter than the function timeout
Why โ VPC-attached Lambdas have no internet unless routed via NAT.
Interview tip โ Most "mystery timeouts" are VPC egress.
Q134 Lambda cold starts hurt latency for a user-facing API. Options?
Intermediate
Situation read โ Reduce init time, or pre-warm capacity.
What I'd do โ
- Enable Provisioned Concurrency on an alias
- Or use SnapStart for Java, Python and .NET
- Shrink package, lazy load libraries, use ARM64
- Avoid VPC-ENI penalties (now small)
- Right-size memory since CPU scales with it
Why โ Provisioned concurrency keeps environments initialized at a cost.
Interview tip โ Memory tuning often cuts duration and cost together.
Q135 Your Lambda scaled so much it overwhelmed a downstream database. How do you cap it?
Intermediate
Situation read โ Reserved concurrency limits the function.
What I'd do โ
aws lambda put-function-concurrency --function-name f --reserved-concurrent-executions 50- Buffer with SQS and set event source
MaximumConcurrency - Add RDS Proxy
- Alarm on
ThrottlesandConcurrentExecutions
Why โ Reserved concurrency is both a guarantee and a ceiling.
Interview tip โ Account concurrency default is 1,000 per region.
Q136 An ECR repo grows to 2 TB of images. How do you control it?
Intermediate
Situation read โ Lifecycle policies expire old images.
What I'd do โ
- Create a lifecycle policy keeping the last 20 tagged
release-*and expiring untagged after 7 days aws ecr put-lifecycle-policy --repository-name app --lifecycle-policy-text file://policy.json- Use
--image-tag-mutability IMMUTABLEfor release tags - Enable image scanning on push
Why โ Storage is billed per GB-month, and old layers accumulate quietly.
Interview tip โ Preview with the dry-run lifecycle preview.
Q137 Multiple accounts must pull images from one central ECR. How?
Intermediate
Situation read โ Repository policy plus replication if cross-region.
What I'd do โ
- Add a repository policy granting
ecr:BatchGetImage,ecr:GetDownloadUrlForLayerto the account or org ID - The pulling role also needs
ecr:GetAuthorizationToken - Use ECR replication rules for regional copies
- Use pull-through cache for public registries
Why โ Centralizing images gives one scan and promotion point.
Interview tip โ Pull-through cache avoids Docker Hub rate limits.
Q138 Design a CI/CD supply chain for images: scan, sign, and enforce at deploy.
Advanced
Situation read โ Security gates in the pipeline plus admission enforcement.
What I'd do โ
- Build with BuildKit, push to ECR with immutable digest
- Scan with ECR enhanced scanning (Inspector) and fail on Critical
- Sign with Cosign or AWS Signer
- Admission policy (Kyverno or Gatekeeper) verifies signatures and allows only the org ECR
- Deploy by digest not tag
Why โ Digest pinning plus signature verification stops tag-swap attacks.
Interview tip โ Mention SBOM generation.
Q139 An ECS task cannot pull its image from ECR in a private subnet: "CannotPullContainerError". Why?
Intermediate
Situation read โ No network path to ECR or missing execution role permission.
What I'd do โ
- Add interface endpoints
ecr.api,ecr.dkrand an S3 gateway endpoint for layers - Or provide NAT
- Execution role needs
AmazonECSTaskExecutionRolePolicy - Check SG allows 443 to the endpoints
- Retry the service
Why โ Layers are stored in S3, which most people forget when building endpoints.
Interview tip โ S3 gateway endpoint is part of the set.
Q140 Choose between Lambda, Fargate and EKS for a new service.
Intermediate
Situation read โ Based on runtime shape and team capability.
What I'd do โ
- Lambda: event-driven, spiky, short (under 15 minutes)
- Fargate: long-running containers without cluster operations
- EKS: need Kubernetes ecosystem, portability, complex scheduling
- Compare cost at expected steady load
Why โ Operational overhead grows from Lambda to Fargate to EKS.
Interview tip โ Do not choose EKS for resume value.
Q141 Secure an EKS cluster's API endpoint and workloads.
Advanced
Situation read โ Layered security from endpoint to pod.
What I'd do โ
- Make the API endpoint private or restrict public CIDRs:
aws eks update-cluster-config --name prod --resources-vpc-config endpointPublicAccess=false,endpointPrivateAccess=true - Use access entries instead of aws-auth ConfigMap
- Enforce Pod Security Standards restricted
- NetworkPolicies and Security Groups for pods
- Enable control plane logging and GuardDuty EKS protection
Why โ API endpoint exposure is the highest-impact decision.
Interview tip โ Access entries are the current auth method.
Q142 An application on Lambda needs a secret. Should you put it in environment variables?
Intermediate
Situation read โ Env vars are readable by anyone with lambda:GetFunctionConfiguration.
What I'd do โ
- Store in Secrets Manager or SSM Parameter Store SecureString
- Fetch at init and cache, or use the Parameters and Secrets Lambda extension
- Grant
secretsmanager:GetSecretValueon that secret - Use KMS CMK for extra control
Why โ Central storage gives rotation and audit.
Interview tip โ Extension caches calls and cuts cost.
Q143 ECS tasks run out of memory only in production. How do you right-size?
Intermediate
Situation read โ Container insights show actual usage.
What I'd do โ
- Enable Container Insights
- Check
MemoryUtilizedversus reserved - Set a hard
memorylimit and softmemoryReservation - Use load test to find p99 memory
- Alert on OOM exit 137
Why โ Dev traffic rarely resembles production memory behavior.
Interview tip โ Hard limit equals kill, soft limit equals scheduling hint.
Q144 Run a multi-tenant SaaS on EKS with strong tenant isolation. How?
Advanced
Situation read โ Isolation tiers: namespace, node, cluster.
What I'd do โ
- Namespaces with ResourceQuotas, NetworkPolicies, RBAC per tenant
- Dedicated nodes via taints for sensitive tenants
- Pod Identity roles per tenant
- Separate clusters or accounts for regulated tenants
- Observability per tenant labels
Why โ Choose isolation by tenant risk and cost.
Interview tip โ Mention noisy neighbor controls.
Q145 Run a one-off migration container on ECS before each deploy. What pattern?
Intermediate
Situation read โ Run a standalone task as a pipeline step.
What I'd do โ
aws ecs run-task --cluster prod --task-definition migrate --launch-type FARGATE --network-configuration ...- Wait:
aws ecs wait tasks-stopped --cluster prod --tasks <arn> - Check exit code via
describe-tasks - Fail the pipeline on non-zero
- Then deploy the service
Why โ Separating migration from service start avoids race conditions among replicas.
Interview tip โ Use backward-compatible migrations.
Q146 How does an ECS task get AWS permissions at runtime?
Beginner
Situation read โ Through its task role, via a credentials endpoint.
What I'd do โ
- Define
taskRoleArnin the task definition - ECS injects
AWS_CONTAINER_CREDENTIALS_RELATIVE_URI - SDK picks it up automatically
- Never share the instance role with containers
Why โ Per-task roles give least privilege.
Interview tip โ Differentiate task role and execution role.
Q147 Lambda deployments should shift traffic gradually. What do you use?
Intermediate
Situation read โ Aliases with weighted routing or CodeDeploy.
What I'd do โ
- Publish a version:
aws lambda publish-version --function-name f - Alias
liveweights 90/10 - Or SAM
DeploymentPreference: Canary10Percent5Minuteswith alarms - Roll back by shifting alias
Why โ Aliases decouple callers from versions.
Interview tip โ Always call via alias.
Q148 Containers on EKS should scale on SQS queue depth. How?
Intermediate
Situation read โ KEDA scales pods on external metrics.
What I'd do โ
- Install KEDA
- Create a
ScaledObjectwith anaws-sqs-queuetrigger andqueueLength20 - Authenticate using Pod Identity
- Set min and max replicas
- Combine with Karpenter for nodes
Why โ Queue depth reflects work to do better than CPU.
Interview tip โ Scale-to-zero is possible.
Q149 Plan a migration of 200 Docker Compose services to AWS. Where do you start?
Advanced
Situation read โ Triage by complexity and make a landing pattern first.
What I'd do โ
- Classify stateless, stateful, and batch
- Build a standard ECS Fargate template (Terraform module)
- Migrate low-risk services first with weighted traffic
- Move data stores with DMS
- Automate observability and CI templates
Why โ Golden path templates avoid 200 snowflakes.
Interview tip โ Pilot first, then scale.
Q150 An image push to ECR fails with "denied: Your authorization token has expired". What do you do?
Intermediate
Situation read โ ECR tokens last 12 hours.
What I'd do โ
- Re-authenticate:
aws ecr get-login-password --region eu-west-1 | docker login --username AWS --password-stdin 111111111111.dkr.ecr.eu-west-1.amazonaws.com - In CI, run login each job
- Use credential helper
docker-credential-ecr-login
Why โ Tokens are short-lived by design.
Interview tip โ Credential helper avoids manual login.
Observability, Secrets, KMS and CloudFormation
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q151 You need to be paged when 5xx errors on the ALB exceed 2 percent for 5 minutes. How?
Beginner
Situation read โ A CloudWatch alarm using metric math.
What I'd do โ
- Metric math:
100 * m1 / m2with m1HTTPCode_Target_5XX_Countand m2RequestCount - Alarm: 5-minute period, threshold 2, 1 of 1 or 2 of 3 datapoints
- Treat missing data as
notBreaching - Action to an SNS topic wired to PagerDuty or Chatbot
Why โ Percentages beat raw counts, since traffic varies.
Interview tip โ Mention treating missing data deliberately.
Q152 How do you centralize application logs from many EC2 and ECS services?
Beginner
Situation read โ CloudWatch Logs with agents or log drivers, then subscription filters.
What I'd do โ
- EC2 uses the CloudWatch agent with
amazon-cloudwatch-agent-ctl -a fetch-config - ECS uses the
awslogsdriver - Set retention:
aws logs put-retention-policy --log-group-name /app/api --retention-in-days 30 - Subscription filter to Kinesis Firehose to S3 for archive
- Query with Logs Insights
Why โ Retention defaults to never expire, which is a silent cost.
Interview tip โ Always set retention.
Q153 CloudWatch costs exploded. Where do you look?
Intermediate
Situation read โ Usually log ingestion and custom metrics.
What I'd do โ
- Cost Explorer by usage type
DataProcessing-BytesandMetricMonitorUsage - Find noisy log groups with
aws logs describe-log-groupssorted bystoredBytes - Reduce debug logging, set retention, use Infrequent Access log class
- High-cardinality custom metric dimensions are charged per series
- Use EMF carefully
Why โ Ingestion costs around 50 cents per GB, so chatty debug logs dominate.
Interview tip โ Cardinality kills metric budgets.
Q154 Investigate a latency spike across microservices on AWS. What tools do you use?
Intermediate
Situation read โ Follow a trace.
What I'd do โ
- Enable X-Ray or OpenTelemetry via ADOT
- Service map to find slow hops
- Logs Insights with request ID:
fields @timestamp, @message | filter @message like /req-123/ - Correlate with ALB
TargetResponseTime - Check downstream throttling
Why โ Traces show where time went; metrics show that it went.
Interview tip โ Propagate a correlation ID everywhere.
Q155 An auditor asks for proof of every configuration change to security groups for 12 months. What do you provide?
Intermediate
Situation read โ AWS Config timeline plus CloudTrail.
What I'd do โ
- Config records configuration items for
AWS::EC2::SecurityGroup - Retrieve history:
aws configservice get-resource-config-history --resource-type AWS::EC2::SecurityGroup --resource-id sg-0abc - CloudTrail shows who made the call
- Retain in S3 with lifecycle for 12 months
Why โ Config shows what changed, CloudTrail shows who.
Interview tip โ Know the split.
Q156 Auto-remediate any security group opened to 0.0.0.0/0 on port 22.
Advanced
Situation read โ Config rule plus SSM Automation remediation.
What I'd do โ
- Enable managed rule
restricted-ssh - Attach remediation
AWS-DisableIncomingSSHOnPort22or custom runbook - Set automatic remediation with 3 retries
- Notify through EventBridge to Slack
- Exempt tagged bastion exceptions
Why โ Closing the hole in minutes beats ticket queues.
Interview tip โ Include exception handling.
Q157 Where should application database passwords live and how do they rotate?
Intermediate
Situation read โ Secrets Manager with managed rotation.
What I'd do โ
- Create a secret:
aws secretsmanager create-secret --name prod/db --secret-string file://creds.json - Enable rotation:
aws secretsmanager rotate-secret --secret-id prod/db --rotation-rules AutomaticallyAfterDays=30 - Use the multi-user rotation strategy for zero downtime
- App reads at runtime, refreshes on auth failure
Why โ Rotation without redeploy removes the temptation to never rotate.
Interview tip โ Aurora and RDS have managed rotation without custom Lambda.
Q158 Secrets Manager or SSM Parameter Store: when to use which?
Intermediate
Situation read โ Secrets Manager rotates and costs per secret; Parameter Store is cheaper for config.
What I'd do โ
- Parameter Store standard parameters are free, SecureString uses KMS
- Secrets Manager costs about $0.40 per secret per month plus API calls
- Use Secrets Manager for DB credentials and keys needing rotation or cross-region replication
- Use Parameter Store for flags and non-rotated config
Why โ Match cost to need.
Interview tip โ Cross-account sharing is simpler with Secrets Manager resource policies.
Q159 Design KMS key strategy for a multi-account platform.
Advanced
Situation read โ Keys per data domain with tight key policies.
What I'd do โ
- Customer managed keys per account and environment, aliased
alias/app-prod - Key policy delegates to IAM and lists admins separately from users
- Cross-account grants via key policy plus IAM
- Annual rotation enabled:
aws kms enable-key-rotation - Multi-Region keys for DR
Why โ Separate admin and usage permissions so key admins cannot read data.
Interview tip โ Mention deletion waiting period 7 to 30 days.
Q160 An engineer scheduled a KMS key for deletion by mistake. What do you do?
Intermediate
Situation read โ There's a waiting period; cancel it.
What I'd do โ
aws kms cancel-key-deletion --key-id <key>- Then
aws kms enable-key --key-id <key> - Alarm on
ScheduleKeyDeletionevents through EventBridge - Restrict
kms:ScheduleKeyDeletionwith SCP - Audit what the key encrypts
Why โ Deleting a key makes all its data unrecoverable.
Interview tip โ Disable first, delete later.
Q161 Write a CloudFormation template that creates an S3 bucket with encryption and block public access.
Beginner
Situation read โ Declarative resource with properties.
What I'd do โ
- Define
AWS::S3::BucketwithBucketEncryptionSSE andPublicAccessBlockConfigurationall true - Add
DeletionPolicy: Retainfor data - Validate:
aws cloudformation validate-template --template-body file://t.yaml - Deploy:
aws cloudformation deploy --template-file t.yaml --stack-name app-bucket
Why โ Defaults in code remove manual drift.
Interview tip โ Retain policy protects data on stack deletion.
Q162 A CloudFormation stack is stuck in UPDATE_ROLLBACK_FAILED. What now?
Intermediate
Situation read โ A resource cannot return to prior state.
What I'd do โ
- Read events:
aws cloudformation describe-stack-events --stack-name s - Fix the blocking cause, e.g. manually deleted resource
aws cloudformation continue-update-rollback --stack-name s --resources-to-skip LogicalId- Then redeploy
Why โ Skipping gets the stack back to a clean state.
Interview tip โ Avoid manual console changes.
Q163 Detect and handle drift between deployed resources and CloudFormation.
Intermediate
Situation read โ Drift detection compares live to template.
What I'd do โ
aws cloudformation detect-stack-drift --stack-name sdescribe-stack-resource-driftsfor details- Revert in the template or update the stack to correct
- Schedule regular detection
- Restrict console write access to reduce drift
Why โ Drift defeats the repeatability of IaC.
Interview tip โ Prevention with permissions beats detection.
Q164 Roll out a CloudFormation change to 80 accounts safely.
Advanced
Situation read โ StackSets with staged rollout.
What I'd do โ
- Use service-managed StackSets with org targets
- Operation preferences: max concurrent 10 percent, failure tolerance 1 account
- Deploy to canary OU first
- Region order sequence
- Monitor
describe-stack-set-operation
Why โ Failure tolerance stops a bad change early.
Interview tip โ Know RegionConcurrencyType.
Q165 Stack deletion fails because a bucket is not empty. How do you handle it?
Intermediate
Situation read โ CloudFormation will not delete non-empty buckets.
What I'd do โ
- Empty:
aws s3 rm s3://b --recursive, versioned buckets needs3api delete-objectsfor versions - Retry delete
- Or use a custom resource that empties on delete
- Use
Retainfor important buckets
Why โ Safety prevents accidental data loss.
Interview tip โ Versioned buckets also need markers removed.
Q166 You need change previews before applying an infrastructure change.
Intermediate
Situation read โ Change sets.
What I'd do โ
aws cloudformation create-change-set --stack-name s --change-set-name c1 --template-body file://t.yamldescribe-change-setto see replacements- Look for
Replacement: Trueon stateful resources execute-change-setafter review
Why โ Replacement of a database is a data-loss event.
Interview tip โ Use stack policies for protected resources.
Q167 Implement CloudTrail for tamper-proof audit logs across an organization.
Advanced
Situation read โ Org trail into a locked log archive.
What I'd do โ
- Create an organization trail with log file validation
- Deliver to S3 in the log-archive account with bucket policy and Object Lock
- Encrypt with KMS
- Send to CloudWatch Logs for alerts
- Validate:
aws cloudtrail validate-logs --trail-arn ... --start-time ...
Why โ Log file validation produces digests that expose tampering.
Interview tip โ Add CloudTrail Lake for query.
Q168 Alert on any root account usage.
Intermediate
Situation read โ Event-based alerting.
What I'd do โ
- EventBridge rule on CloudTrail event with
userIdentity.typeequal toRoot - Route to SNS and pager
- Also detect via Config and Security Hub
- Enforce with SCP denying root actions in member accounts
Why โ Root should be almost never used.
Interview tip โ Centralized root management exists in Organizations.
Q169 Build a dashboard and SLO alarm for an API.
Intermediate
Situation read โ Golden signals.
What I'd do โ
- Metrics: latency p99, errors, traffic, saturation
- Dashboards via CloudFormation
- Composite alarms to cut noise
- Anomaly detection alarm for traffic
- Error budget burn rate alarms
Why โ Composite alarms reduce pager fatigue.
Interview tip โ Alert on symptoms, not causes.
Q170 What does GuardDuty do and how do you enable it org-wide?
Beginner
Situation read โ Threat detection from logs.
What I'd do โ
- Delegate an admin account
aws guardduty create-detector --enable- Auto-enable for new org accounts
- Findings to Security Hub and EventBridge
- Enable EKS, S3, Malware Protection plans
Why โ No agents required.
Interview tip โ Needs response runbooks, not just enabling.
Q171 Respond to a GuardDuty finding: UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.
Advanced
UnauthorizedAccess:IAMUser/InstanceCredentialExfiltration.Situation read โ Instance role credentials used from outside AWS.
What I'd do โ
- Revoke sessions: attach
AWSRevokeOlderSessionsstyle deny withaws:TokenIssueTimecondition - Isolate instance with a quarantine SG
- Snapshot disk and memory for forensics
- Review CloudTrail for actions
- Enforce IMDSv2 and rotate secrets
Why โ Revoking sessions invalidates stolen tokens.
Interview tip โ Isolate before terminate.
Q172 Make secrets available to ECS tasks without putting them in the task definition in plaintext.
Intermediate
Situation read โ Reference secrets by ARN.
What I'd do โ
- In container definition use
secrets: [{name: DB_PASS, valueFrom: <secret-arn>}] - Execution role needs
secretsmanager:GetSecretValueandkms:Decrypt - Value is injected at start
- Restart tasks after rotation
Why โ Plain env vars appear in console.
Interview tip โ Injection happens only at task start.
Q173 How do you enforce that every CloudFormation or Terraform change is reviewed for security before deploy?
Intermediate
Situation read โ Policy as code in CI.
What I'd do โ
- Run
cfn-guard validateorcheckovon templates in pull requests - Fail on high severity
- Require approval in the pipeline
- Use SCP as the backstop
- Report in Security Hub
Why โ Shifting left is cheaper than detecting later.
Interview tip โ Policies in version control are auditable.
Cost Optimization and Disaster Recovery
๐ฅ Learn this hands-on with DevOps Shack โ YouTube @devopsshack ยท Hindi @shackverse ยท Courses at devopsshack.com
Q174 Your AWS bill jumped 40 percent this month. How do you find the cause?
Beginner
Situation read โ Start with Cost Explorer grouped by service, then account, then usage type.
What I'd do โ
- Cost Explorer daily view grouped by Service to find the day it jumped
- Drill by Usage Type and Linked Account
- Filter by tag to find the team
- Check Cost Anomaly Detection alerts
- Cross-check CloudTrail for the launch event
Why โ Daily granularity points to a specific change.
Interview tip โ Set budgets with alerts so you hear first.
Q175 Set up budgets so no one is surprised by spend.
Beginner
Situation read โ AWS Budgets with alerts and optional actions.
What I'd do โ
aws budgets create-budgetfor monthly cost with 80 percent and 100 percent thresholds- Notify SNS and email
- Forecast alerts
- Budget actions can attach a deny SCP or stop instances in dev
- Cost Anomaly Detection monitors per service
Why โ Forecast alerts warn before the money is spent.
Interview tip โ Use per-account budgets.
Q176 Dev environments run 24/7 but are used 9 to 6 on weekdays. How do you cut cost?
Intermediate
Situation read โ Schedule them off.
What I'd do โ
- Instance Scheduler on AWS or EventBridge Scheduler calling SSM
AWS-StopEC2Instance - Scale ASGs to zero at night
- Stop RDS (auto-restarts after 7 days) or use Aurora Serverless v2 min capacity
- Tag
schedule=office-hours - Report savings
Why โ Running 50 hours instead of 168 saves about 70 percent.
Interview tip โ Mention RDS 7-day restart.
Q177 Find and remove idle and orphaned resources.
Intermediate
Situation read โ Unattached volumes, idle load balancers, old snapshots, unused EIPs.
What I'd do โ
aws ec2 describe-volumes --filters Name=status,Values=available- Unused ELBs with zero requests via CloudWatch
- Trusted Advisor and Compute Optimizer idle findings
- Snapshots without AMIs
- Review NAT gateways with no traffic
Why โ Orphans pile up after teardown with no owner.
Interview tip โ Tag owner on everything.
Q178 Reduce data transfer cost in a media-heavy architecture.
Advanced
Situation read โ Data egress usually tops the bill.
What I'd do โ
- Serve through CloudFront, cheaper per GB than S3 direct egress and with a free tier
- Use CloudFront committed-use savings bundle
- Compress
- Keep inter-AZ traffic low
- Use endpoints to avoid NAT per-GB charges
- Consider S3 Intelligent-Tiering only for storage, not transfer
Why โ Egress tiers favour CDNs at volume.
Interview tip โ Always ask where the bytes flow.
Q179 Choose S3 storage classes for data accessed unpredictably.
Intermediate
Situation read โ Intelligent-Tiering.
What I'd do โ
- Move objects with lifecycle to
INTELLIGENT_TIERING - Frequent, Infrequent, Archive Instant tiers automatically
- Optional archive tiers
- No retrieval charges
- Small objects under 128 KB are not tiered
Why โ It removes guesswork for unknown patterns.
Interview tip โ Monitoring fee per object applies.
Q180 Define RPO and RTO and map them to AWS DR strategies.
Beginner
Situation read โ RPO is acceptable data loss; RTO is acceptable downtime.
What I'd do โ
- Backup and restore: hours RTO, cheapest
- Pilot light: core data replicated, compute off
- Warm standby: scaled-down full stack running
- Multi-site active-active: near-zero RTO and RPO
- Choose per workload criticality
Why โ Cost rises as targets shrink.
Interview tip โ State both numbers when asked.
Q181 Design warm standby DR for a web app and database in another region.
Advanced
Situation read โ Aurora Global Database plus scaled-down stack.
What I'd do โ
- Aurora Global Database replica in the DR region, lag usually under a second
- Minimal ASG or ECS service running
- S3 CRR and replicated secrets and ECR
- Route 53 failover with ARC
- Promote:
aws rds failover-global-cluster --global-cluster-identifier g --target-db-cluster-identifier dr-cluster - Scale up and cut DNS
Why โ Warm standby shortens recovery to minutes.
Interview tip โ Test it twice a year.
Q182 Your DR region lacks capacity when you fail over. How do you prevent that?
Advanced
Situation read โ Capacity is not guaranteed in a regional event.
What I'd do โ
- Pre-provision critical capacity or buy On-Demand Capacity Reservations
- Keep warm standby at meaningful size
- Avoid relying on control plane at failure time
- Increase service quotas in the DR region
- Run failover drills
Why โ Many teams discover quota limits mid-incident.
Interview tip โ Static stability.
Q183 Recover an accidentally deleted EBS volume or EC2 instance.
Intermediate
Situation read โ Needs prior snapshots or AMI.
What I'd do โ
- Use Data Lifecycle Manager or AWS Backup schedule
- Restore a volume:
aws ec2 create-volume --snapshot-id snap-0abc --availability-zone eu-west-1a - Recycle Bin for snapshots and AMIs retention rules
- Attach and mount
- Verify
Why โ Recycle Bin protects against deletion mistakes.
Interview tip โ Enable it for AMIs and snapshots.
Q184 A region-wide outage hits us-east-1. Which dependencies could still break a multi-region app?
Intermediate
Situation read โ Some global control planes live in us-east-1.
What I'd do โ
- IAM and Route 53 control planes are in us-east-1; data planes remain available
- Pre-create resources, avoid creating new IAM or DNS changes during failover
- ACM certificates for CloudFront
- Cross-region replicated secrets and images
- Use ARC data plane routing controls
Why โ Static stability means failover requires no control plane calls.
Interview tip โ Mention the Dec 2021 and Oct 2025 style events.
Q185 Run a game day to validate your DR plan.
Advanced
Situation read โ Practice with real failures.
What I'd do โ
- Define steady state and hypotheses
- Use AWS Fault Injection Service to stop instances or block AZ network
- Execute failover runbook, time RTO
- Verify data integrity
- Record gaps and fix
Why โ Only drills reveal hidden dependencies.
Interview tip โ Run them in prod-like environments with guardrails.
Q186 Use Savings Plans and Spot together without overcommitting.
Intermediate
Situation read โ Layer purchases by predictability.
What I'd do โ
- Cover baseline with Savings Plans
- Cover variable with On-Demand
- Cover fault-tolerant with Spot
- Track coverage and utilization
- Review monthly
Why โ Utilization below 95 percent signals overcommit.
Interview tip โ Know coverage versus utilization.
Q187 Build a FinOps process across 100 accounts.
Advanced
Situation read โ Visibility, accountability, optimization.
What I'd do โ
- CUR delivered to S3 and queried with Athena or QuickSight
- Mandatory tags through tag policies
- Showback dashboards per team
- Monthly review of Compute Optimizer and idle findings
- Central commitment management in the payer account
Why โ Teams change behavior when they see their own costs.
Interview tip โ Mention unit costs like cost per request.
Q188 What is the AWS Free Tier trap for new accounts?
Beginner
Situation read โ Free tier has limits and expiry.
What I'd do โ
- 12-month offers expire
- Set a zero-spend budget
- Delete resources when done
- Check Billing dashboard Free Tier usage
- Avoid leaving NAT gateways or Elastic IPs
Why โ NAT gateways and public IPv4 incur charges immediately.
Interview tip โ Beginners should set budgets first.
Q189 Reduce RDS cost without hurting performance.
Intermediate
Situation read โ Right-size and commitment.
What I'd do โ
- Check CPU and memory via Performance Insights
- Move to Graviton instances (db.r7g)
- Use gp3 storage
- Buy RDS Reserved Instances
- Drop unused read replicas and old snapshots
Why โ Graviton gives better price performance.
Interview tip โ Reserved Instances still matter for RDS.
Q190 Choose between Multi-AZ and Multi-Region for a database.
Intermediate
Situation read โ They solve different failures.
What I'd do โ
- Multi-AZ protects against instance and AZ failure with automatic failover
- Multi-Region protects against regional disasters with manual or orchestrated failover
- Add cross-region read replica or global database
- Combine both for critical systems
- Cost doubles roughly per region
Why โ Match scope to the threat.
Interview tip โ Multi-AZ is not a backup.
Q191 Design cross-account disaster recovery for ransomware where the attacker has prod admin.
Advanced
Situation read โ Assume prod account compromise.
What I'd do โ
- Isolated recovery account with immutable vaults
- Backup Vault Lock compliance mode
- Logically air-gapped vault
- Separate identity path and break-glass
- Rehearse clean-room restore
Why โ Attackers cannot delete what they cannot reach.
Interview tip โ Compliance mode cannot be shortened even by root.
Q192 Estimate the cost of a new architecture before building it.
Intermediate
Situation read โ AWS Pricing Calculator plus assumptions.
What I'd do โ
- List components and quantities
- Use the calculator and export
- Add data transfer and logging
- Add 20 percent margin
- Compare against measured pilot
Why โ Hidden costs are NAT, logs, and cross-AZ.
Interview tip โ Validate with a pilot.
Q193 Switch workloads to Graviton. What is the migration path?
Intermediate
Situation read โ Check architecture compatibility.
What I'd do โ
- Rebuild images multi-arch with
docker buildx build --platform linux/amd64,linux/arm64 - Test in staging on
m7g - Update AMIs
- Canary then roll
- Measure price-performance
Why โ ARM gives lower cost per unit work.
Interview tip โ Native dependencies are the trap.
Q194 Meet a 4-hour RTO with low cost for a mid-tier internal app.
Intermediate
Situation read โ Pilot light or backup restore.
What I'd do โ
- IaC for full stack in the DR region
- Cross-region snapshots through AWS Backup
- Runbook to deploy and restore
- Time a restore test
- Document DNS cutover
Why โ IaC makes rebuild minutes not days.
Interview tip โ Prove it with a timed test.
Q195 What backup would you set for an EC2 fleet and how do you verify it?
Beginner
Situation read โ Centralized backup with tests.
What I'd do โ
- AWS Backup plan with daily rule, 35-day retention, tag selection
- Copy to another region
aws backup start-restore-jobin a test- Verify application boots
- Alarm on failed jobs
Why โ Restore tests find silent failures.
Interview tip โ Backups need alarms.
Q196 Optimize S3 costs for 2 PB of logs mostly never read.
Intermediate
Situation read โ Archive tiers and compression.
What I'd do โ
- Lifecycle to Glacier Instant, Flexible, Deep Archive
- Compress and convert to Parquet
- Reduce small objects
- Set expiration
- Use S3 Storage Lens
Why โ Deep Archive costs about $1 per TB per month.
Interview tip โ Retrieval times and fees matter.
Q197 Plan a landing zone from scratch for a startup growing to 50 engineers.
Advanced
Situation read โ Start simple with a scalable skeleton.
What I'd do โ
- Create Organizations with Security, Infra, Workloads OUs
- Control Tower with guardrails
- Identity Center with an IdP
- Network account with Transit Gateway later
- Baseline CloudTrail, Config, GuardDuty
- Account vending through IaC
Why โ Retrofitting accounts later costs far more.
Interview tip โ Start with accounts per environment.
Q198 The CFO wants to know unit cost per customer. How do you measure?
Intermediate
Situation read โ Tag by tenant or allocate shared costs.
What I'd do โ
- Tag resources
tenantwhere possible - Split Cost Allocation Data for EKS and ECS
- Use CUR and Athena
- Allocate shared by usage metrics
- Report cost per active customer
Why โ Unit economics guides pricing.
Interview tip โ Split cost allocation covers containers.
Q199 Leadership wants to leave one cloud region for a second one for compliance with data residency. How do you plan the multi-region data layer?
Advanced
Situation read โ Data residency means some data must never leave its region, so replication design is a legal decision before a technical one.
What I'd do โ
- Classify data by residency rule and tag it
- Keep regulated stores single-region with in-region Multi-AZ and in-region backups only
- Replicate only non-regulated or anonymized data across regions
- Enforce with SCP region deny, S3 replication rules scoped by tag and KMS keys that are single-region
- Document and test with a Config rule that flags cross-region replication on tagged resources
Why โ A single misconfigured replication rule can violate residency, so enforcement must be automated, not procedural.
Interview tip โ Use single-Region KMS keys for regulated data so ciphertext cannot be decrypted elsewhere.
Q200 What does the AWS shared responsibility model mean in practice for an EC2 web server?
Beginner
Situation read โ AWS secures the cloud itself; you secure everything you put in it.
What I'd do โ
- AWS: hardware, hypervisor, facilities, managed-service internals
- You: guest OS patching, security groups, IAM, application code, data encryption choices
- For RDS the line moves up: AWS patches the engine, you own parameters, access and data
- Document the split per service in your security review
Why โ The line moves up the stack as you adopt more managed services.
Interview tip โ Give one EC2 and one RDS example to show you understand the shift.