Tutorial Dojo - DVA-C02 - Timed Mode Set 1

Domain 1: Development with AWS Services

NoQARef
1Improve performance of S3 uploadMultipart upload
2Caching: Lazy-load & Write-through
3Lambda: Different parameter depends on environmentEnvironment variable (# Stage variable)
4AWS SAM: shift traffic to new versionSAM Deployment strategySAM - Deploying gradually
- AllAtOnce (1 deploy)
- Canary 10% 5, 10, 15, 30 min (2 deploys)
- Linear 10% Every 1, 2, 3, 10 min
5API Gateway: same API Gateway for multiple environmentsStage variable
6CloudWatch Alarm: When to alarm?Period / Evaluation Periods / Data points to Alarm
7SAM: Nested applicationAWS::Serverless::Application
8Lambda 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 )
9API Gateway: Map data for microservice (in container)Use HTTP integration (Not AWS or _PROXY)
10Database scale globally, handle frequent schema changesDynamoDB (not Aurora)
11API Gateway - TTL 300s. How client can invalidate cache?Send request with Cache-Control: max-age=0 header
12Lambda: Response to user after 5 minLambda Invoke API InvocationTypeInvoke - InvocationType
- RequestResponse: Synchronous invocation
- Event: Asynchronous invocation
- DryRun: Validate params/role
13Session data store on DynamoDB. Delete session of logged out users?Use DynamoDB TTL (when will an item is eligible for expiration - in epoch time)
14S3: Remove PII before return to applicationUse S3 Object Lambda to process object before return to applicationS3 Object Lambda S3 Object Lambda Use with CloudFront
15Serve content based on location- CloudFront can add header about viewer location’s location (based on the viewer’s IP address).
- Use a CloudFront function to return the URL base on these headers (e.g. CloudFront-Viewer-Country)
16What 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
2. aws cloudformation deploy: Update (deploy) the Cfn stack
17Multi-thread key-value cache storeElasticache for Memcached
18Only allow authorized clients to invalidate an API Gateway cache- API Gateway Additional settings / Per-key cache invalidation / Require authorizationInvalidate an API Gateway cache entry
- Client send request with Cache-Control: max-age=0 header.
19Process long-running tasksElastic Beanstalk worker environment (an HTTP request handler that EB invokes with an SQS queue)
20ECS: Where to config port for container?Task definition
21Lambda: 50 requests/s; 100 s/request 👉️ 5.000 concurrency executionDefault quota of Lambda concurrency execution: 1.000 (can be increased to 10.000)
22Can Lambda handle 10 requests/s (each request take 50s)500 concurrent execution (Lambda can handles without doing anything. The default limit is 1.000)
23DynamoDB 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.
24Kinesis Data Streams: How many worker is optimal to process a number of shards?1:1 ratio
25AWS CLI timeout when list bucket with 10.000 objectsAdd pagination parameter when use AWS CLI
26Permission to Create/Delete GitCommit reposcodecommit:CreateRepository & codecommit:DeleteRepository
27DynamoDB Streams: Send a copy of old item to S3StreamViewType: OLD_IMAGE

Domain 2: Security

NoQARef
1Give a program to AWS services- Best practice: EC2 instance profile (IAM Role)
- On premise: Long-term credential
2Share DB endpointUse System Manager Parameter Store secure string
3Database credential - How to encrypt & auto rotate?- AWS Secret Manager + Enable auto rotate
- IAM DB Authentication: Authenticate connection with IAM
4API Gateway: Allow another account invoke via IAM Role1. From the other account, grant permission to interact with this API GatewayManaging access to API Gateway
2. From this account, attach a resource-policy to API Gateway that grant the IAM role from other account permission to invokeAllow roles in another AWS account to use an API
5Grant permission to access only some path of a S3 bucketUse S3 bucket policy, with the policy statement Resource including the path
6Login with social site: Facebook…, then access to AWS serviceCognito Identity Pool (Federated Identity)
7S3 - Encrypt AE256x-amz-server-side-encryption: AE256
8S3 - Ensure all objects are encryption at rest with SSE-KMSAdd a bucket policy which denies any s3:PutObject action unless the request includes the x-amz-server-side-encryption header.
9KMS - Generate data key but not use immediatelyGenerateDataKeyWithoutPlaintext

Domain 3: Deployment

NoQARef
1Implement subscription with API GatewayUse usage plan to distribute APIs & throttle usages based on defined limit/quotaAPI Gateway - Usage plan
2Lambda, pause task & wait for external processStep Function - Callback pattern (SQS + SNS + Lambda)Step Function - Callback Pattern
- waitForTaskToken
- SendTaskSuccess (with the task token)
3Deploy Lambda with CodeDeployCodeDeploy deploy configuration:
- EC2, on-premise: AllAtOnce, HalfAtATime, OneAtATime (Can be Blue/Green or in-place)
- Lambda, ECS: AllAtOnce, Canary, Linear
4Build, test, deploy serverless appServerless Application Model (SAM)
5SAM template requires sectionsTransform & Resources
6Create Lambda function with CLI error InvalidParameterValueExceptionInvalid parameter: maybe a role can’t be assumed
7ECS schedule task based on CPU/memoryECS - Task placement strategy: binpack, spread, random

Domain 4: Troubleshooting and Optimization

NoQARef
1Move session data to AWS, 100% CPU, HAElastiCache for Redis
2sam local - Access denied1. aws configure --profile; 2. sam local invoke --profile
3Cost effective when using SQSLong polling (config ReceiveMessage WaitTime)
4Record all changes to a DynamoDB table to another oneDynamoDB Streams + Lambda (write to another DynamoDB table)
5DynamoDB - Reduce queriesDAX
6Serve private content from CloudFront1. Use signed-URL, sign-cookies
2. Use Lambda@Edge + Cognito 👉️ Authentication@Edge
7X-ray: How to debug?_X_AMZN_TRACE_ID + AWS_XRAY_CONTEXT_MISSING
8ECS store data in DynamoDB, how to verify each new items?DynamoDB Streams + Lambda
9API Gateway - 504504 Gateway timeout -> Integration timeout after 30s
10RDS - Too many connectionsRDS Proxy
11API Gateway timeout - Which CW metrics to watch?Latency, IntegrationLatency
12CloudFront HTTPSViewer Protocol Policy: Only HTTPS or Redirect HTTP to HTTPS
13CloudFront - end-to-end SSLViewer Protocol Policy, Origin Protocol Policy: HTTPS
14DynamoDB Scan improve performance- Default page size: 1MB (Max) -> Reduce page size
- Use Query instead of Scan
15Capture IP in/out of an VPCVPC Flow Log
16Elastic Beanstalk config for cron-jobcron.yaml
17DynamoDB - Fetch only some attributesUse projection attributes
18Lambda function download same big fileUse /tmp
19Use Lambda function inside a VPC- By default, Lambda is public (has internet access)
- After enable VPC for a Lambda function, it lose internet access,
- If you require internet access for Lambda function:
1. Add a NATGW to VPC
2. Allow outbound traffic with security group
20X-Ray filter trace1. Add annotation to record data used to group traces (indexed to used with filter expression)
(metadata is extra data about data that isn’t indexed )
2. Use filter expression to group traces in the console
21App deploy with Elastic Beanstalk - Config X-Ray.ebextensions/xray-daemon.config
22API Gateway: Lambda Proxy - 502 Bad GatewayIn Lambda proxy integration, the backend Lambda function must return output according a JSON formatOutput format of a Lambda function for proxy integration