Tutorial Dojo - DVA-C02 - Summary

Domain 1: Development with AWS Services

NoQA
I.1✅Improve performance of S3 uploadMultipart upload. How about Transfer Acceleration?
I.2✅Caching: Lazy-load & Write-through
I.3✅Lambda: Different parameter depends on environmentEnvironment variable (# Stage variable)
I.5✅API Gateway: same API Gateway for multiple environmentsStage variable
I.6✅CloudWatch Alarm: When to alarm?Period / Evaluation Periods / Data points to Alarm
I.7✅SAM: Nested applicationAWS::Serverless::Application
I.8✅Lambda deploy: Graduate increase traffic to new versionLambda supports traffic shifting for aliases (by setting traffic weight). (That’s why SAM have canary, linear deployment strategy )
I.9✅API Gateway: Map data for microservice (in container)Use HTTP integration (Not AWS or _PROXY)
I.10✅Database scale globally, handle frequent schema changesDynamoDB (not Aurora)
I.11✅API Gateway - TTL 300s. How client can invalidate cache?Send request with Cache-Control: max-age=0 header
I.13✅Session data store on DynamoDB. Delete session of logged out users?Use DynamoDB TTL (when will an item is eligible for expiration - in epoch time)
I.15✅Serve content based on location- CloudFront can add header about viewer location’s location (based on the viewer’s IP address).
I.16✅What to do after update Cfn template of a Lambda function?1. aws cloudformation package: Uploads local artifacts to S3, update Cfn template to reference these artifacts
I.17✅Multi-thread key-value cache storeElasticache for Memcached
I.19✅Process long-running tasksElastic Beanstalk worker environment (an HTTP request handler that EB invokes with an SQS queue)
I.20✅ECS: Where to config port for container?Task definition
I.22✅Can Lambda handle 10 requests/s (each request take 50s)500 concurrent execution (Lambda can handles without doing anything. The default limit is 1.000)
I.23✅DynamoDB table attributes: UserID (PK) - GameTitle (SK) - TopScore. Get max TopScore of each game?Create a Global Secondary Index: GameTitle (PK) - TopScore (SK). Query 1 item for each game in descending order.
I.24✅Kinesis Data Streams: How many worker is optimal to process a number of shards?1:1 ratio
I.25✅AWS CLI timeout when list bucket with 10.000 objectsAdd pagination parameter when use AWS CLI
I.26✅Permission to Create/Delete GitCommit reposcodecommit:CreateRepository & codecommit:DeleteRepository
I.27✅DynamoDB Streams: Send a copy of old item to S3StreamViewType: OLD_IMAGE
II.1✅RDS + Lambda + Translate text with Amazon Translate. Improve performance, reduce load to RDS?Use Lambda execution environment /tmp as cache store
II.2✅DynamoDB: Employee info. Which attribute use as primary key?employee_id
II.3✅Run a Lambda function every 30min?Use EventBridge Schedule Rule to create scheduled events -> target the Lambda function
II.4✅ECS integrate with API Gateway. Which integration make no intervention?HTTP_PROXY
II.5✅Which API to call to get permission (from a IAM Role) to interact with S3 APIAWS STS AssumeRole API (or AssumeRoleWithWebIdentity, AssumeRoleWithSAML) (optionally pass an SessionPolicy)
II.6✅Asynchronous invoke Lambda function with Invoke APIPass parameter InvocationType - Event
II.11✅DynamoDB: Write heavy - ProvisionedThroughputExceededException. Why?RCU/WCU of GSI is separate from base table
II.12✅CodeCommit: Permission to fetch, clone, pushcodecommit:GitPull, codecommit:GitPush
II.13✅Elastic Beanstalk: Deploy new version with CLIPackage app as zip/war file. Deploy with eb deploy (EB CLI is a different package. It’s not packaged with AWS CLI, not aws eb)
II.14✅Internal app: elastic, cost-effectiveDynamoDB, EC2 Spot Fleet
II.15✅Build an CI/CD to deploy to both EC2 & on-premise. Which service?CodeDeploy
II.16✅DynamoDB: 10 RCU, each item 4KB. How much read request/s the table can handle?10 RCU: 10 Strong Consistency Read - 20 Eventually Consistency Read
II.17✅Prototype microservices on ECS. Which task placement minimize cost?Binpack, random, spread
II.18✅Temporary AWS credential for both authenticated/unauthenticated. Which service?Cognito Identity Pool (Federated Identity)
II.20✅SQS: Duplicated messages. How to fix?For SQS, when call SendMessage API, add MessageDeduplicationId param
II.21✅DynamoDB: Protect from overwritten?Implement optimistic locking with version number (ensure update the right version item)
II.22✅Lambda: Asynchronous invoke, exponential back-off, then send un-processed messages to another service.Lambda supports Dead Letter Queue (just as SQS DLQ)
II.23✅Collect visitor click to ads. Which service?DynamoDB: Use UpdateItem to implement atomic counter (Approximately ~ Add 1 to previous value)
II.24✅DynamoDB: Read 100 items. Which API?BatchGetItem (instead of GetItem) then BatchWriteItem
II.25✅DynamoDB: Store recent updated item automatically1. DynamoDB Streams + Lambda (not recommend)
II.26✅DynamoDB: Session data. Reduce storage without using provision throughputUse DynamoDB TTL
II.27✅Kinesis Data Streams: How to handle data flow (Scaling)?1. Split shards to increase stream capacity; 2. Merge shards to decrease stream capacity.
II.28✅Kinesis Data Streams: Consumer process every other day & store to S3. S3 only has half of the data?Kinesis Data Streams default retention period is 24h (up to 365 days)
II.29✅An AWS account has 2 Lambda function. 1 works optimal, 1 is throttled. Why?The reserve concurrency execution of function 1 is higher
II.30✅Lambda: Process events from S3 Events. 10 events/s, each event takes 3s. How much concurrency?Concurrency: number of in-flight request AWS Lambda function is handling at the same time.
II.32✅Protect AWS APIs call with MFAMFA-enabled IAM users must call GetSessionToken and submit an MFA code that is associated with their MFA device.
II.34✅Website hosted on S3 bucket_A, make GET request to S3 bucket_B. API calls are blocked by browsers?Enable CORS on bucket_B
II.35✅Migrate repos from Github to CodeCommit1. Create repos on CodeCommit; 2. Clone repos from Github; 3. Push to CodeCommit repos
II.36✅Lambda: Increase CPU?By increase memory
II.37✅ECS: Integrate with X-Ray. How to provide more granular timing information?Use sub-segment
II.38✅Version control system. Which service?CodeCommit
II.39✅API Gateway: Non-proxy integration with Lambda. How to ensure consumer include a query string?Use method request
III.1✅Replace spreadsheet-based tracking system. DynamoDB.EDA: DynamoDB Streams + Lambda + SNS
III.2✅Collect real-time user dataKinesis Data Streams
III.4✅CodeCommit, CodeBuild, CodeDeploy, CodePipeline. A central dashboard?CodeStar
III.5✅Cfn: Reuse value from a stack?Outputs/Export & Fn::ImportValue
III.6✅Hundreds of thousands of reads/writes per second. Which database?DynamoDB
III.7✅DynamoDB: Bidding system.DynamoDB Streams + Lambda + Conditional Write
III.8✅DynamoDB: Query a single tableLSI (when create the table)
III.9✅DynamoDB: Throttled. Hot partition. Fix minimal effort?Refactor to evenly distribute between partitions; Retries with exponential backoff
III.10✅CodeCommit: Setup?1. Git credential - HTTPS (username/password); 2. SSH connection (SSH key-pair)
III.11✅DynamoDB: 1.5KB. Write 100 items/s. WCU 100 but throttled. Fix?Increase WCU to 200.
III.13✅SQS: Duplicate messageSQS FIFO + SendMessage with DeduplicationID
III.15✅ECS: Place task between AZs?Spread
III.17✅Sync user data without your backend.Cognito Sync (delegated use AppSync)
III.21✅SQS: Config Dead Letter QueueJust provide ARN of the queue to DeadLetterConfig
III.22✅Elastic Beanstalk: Web app process large number of items from DynamoDB. Overload. Easiest fix?Use Batch operations for Get, Put, Delete
III.23✅DynamoDB: Send welcome mail for new user. How?DynamoDB Streams + Lambda + SNS
III.24✅DynamoDB: Table - FighterID (PK) - FilterTitle (SK). Query by other attributes?Create a GSI
III.25✅DynamoDB: + Elasticache. Write data if cache miss. Improve?Add write-through + TTL
III.26✅Kinesis Data Streams: 100 shards, Lambda (10 seconds/request, 50 items/seconds)Maximum of 100 Lambda concurrency = number of shards
III.27✅Cfn: How to automate the process of getting latest AMI?Use System Managers Parameter Store
III.28✅SQS: Process tool long & messages appear twiceIncrease visibility timeout
III.29✅CloudFront: Slow to login & 504Authentication@Edge + Origin fail over
III.30✅Lambda: Increase CPU?By increasing memory
III.31✅API Gateway: Implement APIs form current Swagger spec.Just import the OpenAPI/Swagger file.
III.32✅Microservice using Docker + Fine-grain controlECS
III.33✅Quickly deploy Node app (provisioning, load balancing, ASG…)Elastic Beanstalk
III.34✅Amplify: config?amplify.yaml
III.35✅S3: Cross-Region Replication. Fail. Why?Maybe Object Versioning is not enable
III.36✅S3: Upload Terabytes of data from over the worlds. Slow. Improve speed?S3 Transfer Acceleration
III.37✅API Gateway: Reuse same function for different stage (different DynamoDB table)Stage variable + mapping template
IV.1✅Automatically watermark images uploaded to S3Use S3 Event Notification s3:ObjectCreate:Put. Send the event to Lambda function (destination) (# S3 Object Lambda)
IV.2✅Lambda function: access RDS in private subnetConnect to the VPC
IV.3✅API Gateway + Lambda: Map incoming request to integration request & vice versaAWS custom (Lambda custom)
IV.4✅Which cache strategy ensured cached data is always up-to-date & stale data are automatically deleted?Write-through + With TTL
IV.5✅DynamoDD: How to prevent data overwritten?Optimistic locking + Conditional writes (check version number)
IV.6✅Database credential: How to encrypted & auto-rotate?Use Secrets Manager + Enable Automatic Rotation
IV.7✅S3: Use SQL to filter & retrieve only a subset data of an object?S3 Select (supports CSV, JSON, Apache Parquet & compressed CSV, JSON)
IV.9✅DynamoDB - GSI: How much throughput to provision?GSI WCU >= Base table WCU
IV.10✅DynamoDB: 2KB items - 10 writes/s - 20 eventually consistent reads/s. How much RCU/WCU?2KB ➡️ 1 strongly consistent read = 1 RCU ➡️ 1 eventually = 0.5 RCU ➡️ 20 eventually = 10 RCU
IV.11✅1 item = 17KB. 320 strongly consistent read/s. How much RCU?17KB/item ➡️ 5RCU/strongly consistent read ➡️ 320 strongly read = 320 x 5 = 1600 RCU
IV.12✅HTML, JS, image, video. How to server with lowest latency around the world?S3 + CloudFront
IV.13✅AI-based app built with Lambda. How to modify the way invocation event are read form Lambda runtime API?Use Lambda custom runtime
IV.14✅Migrate monolith on-premise app to Lambda. Best practice?1. Take advantage of execution runtime; 2. Use environment variable…
IV.16✅Online game - Sync app pref + state of player + Allow multiple player to share stateApp Sync (Cognito Sync not support shared data)
IV.17✅AWS CLI in EC2 instance. How to easily switch role?1. Create a new CLI profile with credential; 2. Run aws CLI with --profile
IV.18✅DynamoDB: Ensure item is updated only some attribute meets some conditionConditional writes
IV.19✅DynamoDB: Debug throughput of both base table & GSI when update item?Call UpdateItem with ReturnConsumedCapacity set to None / Total / Indexes
IV.20✅DynamoDB Streams: How to integrate with Lambda?1. Create an EventSourceMapping to poll the DynamoDB stream, read & process records
IV.21✅Serverless app: Which service can manage configuration & deploy the whole stack + simple?AWS SAM (Serverless Application Model)
IV.22✅DynamoDB: Table: ArticleName (PK) - Category (SK). Query ArticleName using another Sort Key + Strongly consistent readCreate a new table with Local Secondary Index (LSI). Migrate the existing data to new table (LSI cannot be created after the DynamoTB is created)
IV.23✅S3: Ensure all objects are encrypted with AE256Use bucket policy to deny any Create request doesn’t have x-amz-server-side-encryption: AE256 header
IV.24✅EC2: Shell script to get instance public/private IPUse Instance Metadata Service endpoint 169.254.169.254/latest/meta-data
IV.25✅Lambda: Account concurrency limit 2000; 10 functions: 1 function 400, 1 function 200. The rest, the third?The rest: 1400; the third: 1300.
IV.26✅Coordinate multiple services into serverless workflow. Which service?AWS Step Functions
IV.27✅API Gateway: Enable caching. How to invalidate 1 key?Send the request with Cache-Control: max-age=0
IV.28✅Lambda: Connection refused. Why?Maybe the invoke URL is wrong (http without s)
IV.29✅Lambda: Improve performance?Increase memory will increase CPU too.
IV.30✅Lambda: A function initialize DB connection every time it executes. How to optimize?Move the DB connection to shared execution context (outside handler)
IV.31✅Lambda: Can the function built with Rust?Yes. Use custom runtime
IV.32✅Lambda: A function fetch 20MB static data every time it executes. How to optimize?Place the initialize outside Lambda handler; saved external file to /tmp
IV.34✅Online game. How to add feature to cross-sync profile data between device?Use Cognito Sync (or App Sync)
IV.35✅DynamoDB: Which attribute to use as partition key?The partition should uniquely identify each item
IV.36✅CodePipeline: Push build details into a DynamoDB?Use EventBridge & Lambda
V.2✅API Gateway & Lambda: New version. Smooth migrationUpdate Lambda function -> Deploy new version. Specify new ARN in API Gateway integration. Redeploy to new stage.
V.3✅Elastic Beanstalk: Path of config file/.ebextensions/xxx.config
V.4✅Lambda: Ephemeral storage/tmp
V.5✅Lambda: How to use Ruby?Ruby’s natively support
V.6✅CloudFront: Update image immediatelyUse file name versioning
V.7✅Cognito: Authentication with JWT1. Create User Pools
V.9✅S3: Lowest costGlacier Deep Archive
V.10✅EC2: Run Apache web serverUse user-data to install and start Apache web server
V.11✅App host in 1 region. Re-create on other regions using AMI & CloudFormation. How?Use Cfn Mapping & FindInMap
V.12✅Serverless app. Application code & infrastructure code in Python. How?Use CDK and Python
V.13✅Step Functions: Handle error? Aggregate data in different states?Use Catch & ResultPath
V.15✅DynamoDB: Control access to individual items & attributes?Fine-grain access control with
V.16✅Cognito: UI for login page missing brand logoCognito allows customization for: logo, CSS.
V.17✅SQS queue: messages larger than 256KB.Use Amazon S3, (for Java) Extended Client Library
V.20✅API Gateway: Integrate a XML-based SOAP API. How?Use HTTP Integration:
V.21✅Serverless: Send newsletter at 7-day interval. How?Use EventBridge Schedule Rule to create events at 7-day interval, sends the events to Lambda function target
V.23✅DynamoDB: Group multiple actions to multiple items to a one-or-nothing operation?Use TransactionWriteItems
V.24✅DynamoDB: When an item added to Customer table, dynamically update Payment table. How do it in real time?Enable DynamoDB Streams for Customer table, trigger a Lambda function to update Payment table
V.25✅ALB: Obtain all value of identical query parameter key.Enable multi-value headers
V.26✅ECS: 2 containers share logs. How?Define these 2 containers in 1 task definition, use EFS as a volume

Domain 2: Security

NoQA
I.2✅Share DB endpointUse System Manager Parameter Store secure string
I.4✅API Gateway: Allow another account invoke via IAM Role1. From the other account, grant permission to interact with this API Gateway
I.5✅Grant permission to access only some path of a S3 bucketUse S3 bucket policy, with the policy statement Resource including the path
I.6✅Login with social site: Facebook…, then access to AWS serviceCognito Identity Pool (Federated Identity)
I.7✅S3 - Encrypt AE256x-amz-server-side-encryption: AE256
I.9✅KMS - Generate data key but not use immediatelyGenerateDataKeyWithoutPlaintext
II.1✅Cognito - Enforce MFA for suspicious login attemptUser Pool / Adaptive Authentication / Automatic risk response
II.2✅EC2 instance - Upload images to S3. How to give EC2 instance permission?IAM Role (Instance Profile)
II.3✅Dev needs to access Test/Prod accounts. How to give permission?Grant cross-account access:
II.4✅API Gateway - Lambda Authorizer: Implement one that same as OAuth, SAMLAPI Gateway - Lambda Authorizer (Custom Authorizer) has 2 types:
II.5✅EC2 instance has both credentials & Instance ProfileAWS CLI credentials precedence: CLI options > ENVVAR > Assumed Role > IAM Identity (/.aws/config) > Credential file (/.aws/credentials) > EC2 instance profile > Container credential
II.8✅S3 - Encryption using KMS-C. How to upload object?Include the headers: x-amz-server-side​-encryption​-customer- + algorithm/key/key-MD5
II.9✅IAM, SCP - How to test IAM policy?IAM Policy Simulator
III.1✅API Gateway: Lambda authorizer - accepts header, query stringsRequest parameter-based authorizer (REQUEST authorizer)
III.2✅On-premise KMS, migrate to AWS. Key is store in dedicated hardwareCloudHSM
III.3✅S3: Upload small file + Use KMS key: OK. Upload big file (100GB): not OKAWS CLI use multipart upload for big files. It’s required the kms:Decrypt permission
III.4✅S3: SSE with KMS (using default KMS key). Which header?- x-amz-server-side-encryption: aws:kms
III.5✅S3: SSE-C. How does it work?1. You manage key & give AWS the key each time you upload a file
III.6✅KMS: A file encrypted with data encryption key (DEK). How to decrypt the files locally?1. Use KMS’s Decrypt to decrypt the DEK
III.7✅CodeDeploy: Platform: ECS - appspec.yamlappspec.yaml for ECS needs: TaskDefinition, ContainerImage, ContainerPort
III.8✅Share DB connection endpointSystems Manager Parameter Store secure string
III.9✅SSL certificate from 3rd party. Which service can store?AWS Certificate Manager (for unsupported regions, use IAM certificate store)
IV.2✅SSM Parameter Store: Notify if param haven’t been rotated for 90 days1. Use Advanced tier / Parameter polices / Notification policies
IV.3✅S3: Ensure data is encrypted at rest using the company key1. Client-Side Encryption (CSE) - Encrypt the data before send to S3
IV.4✅KMS: Locally encrypt data (Envelope encryption)1. Use the GenerateDataKey API to get a data key.
IV.5✅API Gateway: Custom authorizer using bearer token (same as SAML, OAuth). How?Use API Gateway Lambda authorizer (aka custom authorizer)
IV.6✅Database credential + RotateSecrets Manager + Auto Rotation (How? Secrets Manager run a Lambda function )
IV.7✅CloudFormation: Retrieve license key + cost-effectiveSystems Manager Parameter Store + Secure String
IV.8✅Migrate on-premise to AWS. Integrate LDAP directory service (not compatible with SAML)Implement a custom identity broker, which use STS to issue short-live AWS credentials
IV.9✅Cognito: Additional authentication methodIntegrate Multi-Factor Authentication (MFA) to Cognito User Pool
IV.10✅SQL Server. Migrate to RDS. Encrypt data before write to disk & vice versa.Enable SQL Server Transparent Data Encryption
IV.11✅S3. Someone use your image without permission.(Block public access) Use pre-signed URL / pre-signed cookies
V.2✅S3 bucket in production account. How to allow a user on dev account access?1. In prod acc, create an IAM role
V.3✅S3. Which service to allow user register/sign-in & upload/access images on S3.Cognito User Pools & Identity Pools
V.4✅Allow temporary access to EC2 & but still enforce MFA? Which STS API?STS GetSessionToken
V.6✅API Gateway: Regulate access to API & charge based on usageUsage Plan
V.7✅Best practice to manage access keyRemote all access key of root account, use IAM role for applications
V.8✅Most secure way to send CW logs in EC2 instance of ASG launch configuration- Create a new IAM role for the new Launch Configuration
V.10✅S3: Hundreds of thousands of objects. Turn on SSE-KMS. Performance degradation. Why?Requests to KMS are exceeded quota
V.11✅How to check permission of an IAM role?1. Use IAM Policy Simulator

Domain 3: Deployment

NoQA
I.3✅Deploy Lambda with CodeDeployCodeDeploy deploy configuration:
I.4✅Build, test, deploy serverless appServerless Application Model (SAM)
II.1✅SAM: workflow redeploy1. sam build; 2. sam deploy
II.2✅Elastic Beanstalk: Dev/Test - Deploy ASAPEB deployment strategy: AllAtOnce
II.3✅SAM: deploy 10% every 10minSAM Linear 10min
II.4✅Lambda: package deployment take too much time to deploy? How increase deploy speed?Lambda package deployment quota (for a function) is 50 MB (zipped; includes runtimes, layer…)
II.6✅CloudFormation: Easiest way to deploy a hello_world lambda functionIncline the function in AWS::Lambda::Function Properties / Code / Zipfile
II.7✅Elastic Beanstalk: Upgrade from Java 7 to 8. Shift all traffic to the new one, revert if something’s wrongBlue/Green Deployment: EB AllAtOnce + EB swap environment URLs (EB will use Route 53 to swap CNAMEs)
II.8✅CodeDeploy: Deploy to where? How?CodeDeploy deploy configuration:
III.1✅EC2: EBS-backed root volume. How to detach the root-volume?Stop the EC2 instance, then detach the root volume
III.2✅Elastic Beanstalk: Maintain compute resource while deploying. No downtime.Rolling with additional batch, Immutable
III.3✅DynamoDB: 3.5KB. 150 eventually consistent reads/second. How many RCU?1 strongly read -> 1 RCU
III.4✅Lambda: Deployment package 80MB. What to do now?Split the dependencies to a layer
III.5✅SAM: How to use Cfn & include SAM?Use Cfn Transform & AWS:Serverless macro to process SAM template to Cfn template
III.7✅Cfn: Different accounts. How to manage update across all accounts?Use StackSets
IV.2✅Elastic Beanstalk: HA, revert quickly?1. Use any EB deployment strategy, e.g. All-at-once (fastest)
IV.3✅CloudFormation: Inline code in templateAWS::Lambda::Function / Code / ZipFile
IV.4✅Serverless app: Zip code, upload to S3, produce package deployment-ready template & deploysam deploy (which includes sam package)
IV.5✅CloudFormation: Install packages, start services on EC2 after provisionedcfn-init
V.1✅CodeDeploy: S3 source. Deploy to EC2 fail during DownloadBundleThe EC2 instance profile don’t have permission to access S3 bucket
V.3✅Deploy to 3 environments: test, staging, production. How?Use 3 deployment groups, each for 1 environment.
V.4✅Elastic Beanstalk: Multi-container Docker. Which file to configure container definitions?Dockerrun.aws.json
V.5✅Elastic Beanstalk: Multi developers deploy without upload the whole project?Use eb deploy to deploy from local CodeCommit repo
V.6✅Serverless app defined with CDK. Deploy to new account. NoSuchBucket error. Fix?Run cdk bootstrap to provision resources for CDK deployment, e.g. IAM role, S3 bucket.
V.8✅CodeCommit: Forgot to pull master. Fix conflict?git rebase feature branch on master branch. Then manually fix conflict.

Domain 4: Troubleshooting and Optimization

NoQA
I.1✅Move session data to AWS, 100% CPU, HAElastiCache for Redis
I.2✅sam local - Access denied1. aws configure --profile; 2. sam local invoke --profile
I.3✅Cost effective when using SQSLong polling (config ReceiveMessage WaitTime)
I.4✅Record all changes to a DynamoDB table to another oneDynamoDB Streams + Lambda (write to another DynamoDB table)
I.5✅DynamoDB - Reduce queriesDAX
I.8✅ECS store data in DynamoDB, how to verify each new items?DynamoDB Streams + Lambda
I.9✅API Gateway - 504504 Gateway timeout -> Integration timeout after 30s
I.10✅RDS - Too many connectionsRDS Proxy
I.11✅API Gateway timeout - Which CW metrics to watch?Latency, IntegrationLatency
I.13✅CloudFront - end-to-end SSLViewer Protocol Policy, Origin Protocol Policy: HTTPS
I.15✅Capture IP in/out of an VPCVPC Flow Log
I.16✅Elastic Beanstalk config for cron-jobcron.yaml
I.17✅DynamoDB - Fetch only some attributesUse projection attributes
I.18✅Lambda function download same big fileUse /tmp
I.21✅App deploy with Elastic Beanstalk - Config X-Ray.ebextensions/xray-daemon.config
II.1✅DynamoDB: ProvisionedThroughputExceededOptimize DynamoDB:
II.2✅X-Ray: View full trace without using consoleUse GetTraceSummaries, BatchGetTraces
II.3✅ECS + Docker app: How to setup tracing with X-Ray?- Run xray-daemon inside docker image
II.4✅AWS CLI - TimeoutUse pagination: --page-size (request less items) --max-items (show less items)
II.9✅X-Ray: From where, IP address is fetch?X-Forwarded-For header
III.2✅X-Ray: Insufficient permissions to use X-ray console to view service map, segments. Which manged policy?- AWSXrayReadOnlyAccess
III.3✅API Gateway: Fetch latest data without caching (using Cache-Control: max-age=0 header). Which permission?Resource-based policy for execute-api:InvalidateCache action
III.4✅DynamoDB: Streams, EventBridge + Lambda every 36 hours. Missing data?DynamoDB Streams retention period is 24 hour. Only last 24 hours data is available
III.5✅Kinesis Data Streams: Increasing data flow. Scale up?Split-shard + (increase numbers of worker)
III.6✅S3: CORS config: <AllowOrigin>, <AllowedMethod>, <AllowedHeader>, <MaxAgeSeconds>3600</MaxAgeSeconds>MaxAgeSeconds: time in seconds that your browser can cache the response for a preflight request
III.7✅API Gateway: Lambda. 504. No errors in CW. Why?Lambda function takes more than 30s (API Gateway timeout)
III.8✅RDS: Slow response (in peak time). Already optimize queries. Resolve?- Add Read Replica
III.9✅Latency-sensitive service. AWS Fargate, CloudFront, ALB. Too much unauthenticated users, increase CPU of Fargate. Fix?Use CloudFront Function (attach to Viewer Request) to authenticate users
III.10✅EC2: Monitor memory, swap. How?Install CW Agent
III.11✅Elastic Beanstalk: EC2. CW doesn’t show memory. Why?By default, CW doesn’t track EC2 instance memory
III.12✅Kinesis Data Steams: Producers restart -> Duplicate record. Fix?Call PutRecord with SequenceNumberForOrdering param.
IV.1✅Send traces to X-ray?Use X-Ray daemon (CloudWatch Agent can do this on EC2/On-Premise)
IV.2✅SQS: Duplicate message. Fix?Use FIFO queue + provide deduplicationID
IV.3✅X-Ray: Filter trace?1. Use web console; 2. Use GetTraceSummaries (support search)
IV.4✅X-Ray: Send trace to X-Ray?- 1. Use X-Ray SDK (through X-Ray daemon); 2. Use X-Ray/CLI (directly)
IV.5✅Kinesis: Over-provision. Scale in?Merge cold shards
IV.6✅API Gateway: Terminated Lambda. Why?- Lambda timeout: max 15min ➡️ terminated
IV.7✅API Gateway: No metrics for CacheHitCount/CacheMissCountAPI Gateway caching is not enabled
IV.8✅SQS injections, XSS attack. How to deal?Use Web Application Firewall (WAF). It works with: CloudFront, ALB, API Gateway (REST API)
IV.9✅Kinesis: 10 shards - 10 EC2 instance. Increase to 20 shards, how many instances?20 instances, the number of instances match the number of shards by 1:1 ratio
IV.10✅RDS: Monitor memory, CPU usages of processes?Use RDS enhanced monitoring
IV.11✅CodePipeline: Code review in each stage before move to next stageUse a “manually approval” action, and send the approval request to a SNS topic
IV.12✅X-Ray: Record call to DB, other services, SQL queries & filterAdd annotations in the subsegment section of the segment document.
IV.13✅X-Ray: Permission to send trace to X-Ray?AWSXRayDaemonWriteAccess
V.3✅CodeBuild: Run on a proxy server. RequestError when CodeBuild is accessed. Fix?
V.5✅S3 - Event Notifications: Compress the images, but it takes too much time. Improve?Increase memory ➡️ increase CPU
V.6✅Debug latency of your app (with recently added function)? How to do with X-Ray?Define sug-segments inside the function to “instrument” (measure) it
V.7✅AWS CLI: Create snapshot of EC2 instance. InvalidInstanceID.NotFound. Why?Maybe the AWS CLI is using a profile for a different region
V.8✅Build a CI pipeline. Which AWS services?CodeCommit, Lambda, CodeBuild
V.9✅Step Functions: Handle & recover from State’s exception.Use Catch & Retry fields in state machine definition
V.10✅Lambda - Cold start: Optimize?1. Reduce pre-handler code
V.11✅LAMP stack. Migrate to AWS?EC2 + Aurora/RDS
V.12✅Lambda: process file (5min). So slow?Change InvokeType to Event (asynchronous invocation)
V.14✅Website (hosted on S3) call API Gateway. No "Access-Control-Allow-Origin" error. Fix?Config CORS for API Gateway to allow the website (S3)
V.15✅API Gateway + Lambda: Publish a new version of AccService:Prod with the alias AccService:Beta. How to test before promote?Create a BETA stage. Use stage variable to reference the beta function alias
V.16✅Lambda: Unable to import module. Fix?1. Install the missing module locally.
V.17✅Elastic Beanstalk: Keep the old code in S3 bucket. How?Change Retention to Retain source bundle in S3