You are on page 1of 6

AWS Developer Exam Cheat Sheet

Metrics to remember: Lambda tips API Gateway tips


- To improve cpu performance, increase the - API Cache
Max lambda concurrency 1000 (900 reserved, 100 unreserved) memory (yes, you read that right…) - Capacity
- To reuse db connections or cached expensive - Encrypted: Y/N
Lambda concurrency calculation Request per second * duration per function
E.g 100rps * 5s = 500 concurrent units operations, use execution context - Cache TTL
- To process data locally, use /tmp folder - Require authorization
Kinesis: - To embed code in cloud formation template, - Handle unauthroized requests
concurrent requests = #shards use Zipfile syntax under code. - To clear cache
E.g 100 shards = need 100 concurrent units - Use traffic shifting if you want to shift certain - Set header to Cache-Control:
Max lambda timeout duration 15 minutes percentage of traffic to current and new max-age=0
versions (weight alias) - Grant permission to user
Max API gateway concurrency 10,000 (before throttling kicks in) - Use environment variables if you want to have "Effect":
different configurations per aliases "Allow",
Max S3 object size 5TB - Use aliases when you want to segregate your "Action": [
Lambda /tmp folder size 512 MB
lambda function by env (e.g prod, stage, test) "execute-api:InvalidateCache
- Use dead letter queue if you want to handle "],
DynamoDB RCU calculation 4KB per strongly consistent read (2x for eventually failed async lambda function Resource": [
consistent reads) - You can configure async lambda function by
Scenario: Client wants to read up to 30 rows of customer
setting invocation type to event "arn:aws:execute-api:region:
data per second. Each row is about 8KB. How many
RCU is needed for strongly consistent reads? - Lambda layer is used for packaging libraries account-id:api-id/stage-name
and other dependencies for lambda function. /GET/resource-path-specifier
RCU per row = 8KB / 4KB = 2 RCU Using layers means you can keep your "]
Total RCUs needed = 2 RCU * 30 = 60 lambda footprint small. - To handle environment specific configuration,
For eventual reads, divide answer by 2 - For non-supported programming language, use stage variables
DynamoDB WCU calculation 1KB per write (2x for transactional write) use custom runtime - Use HTTP integration when
Scenario: Client wants to store 100 rows of customer - For VPC access requests/response needs to be mapped
data per second. Each row is 8KB. How many WCU is - Configure the subnet of the VPC to - Use HTTP proxy when mappings are not
required? access required
WCU per row = 8KB * 1 = 8 WCU - Configure the security group of the - Use lambda authorizer for request or token
Total WCUs needed = 100* 8 WCU = 800
VPC based authorization
SQS retention period 14 days - Make sure VPC has a NAT
gateway so that lambda can
access the internet

Http error codes to remember


429 (too many requests) Happens when number of requests exceed API gateway
or lambda function limits

504 (Gateway timeout) API gateway (29 seconds) -> can be configured
API gateway + lambda = Lambda taking longer than 29
seconds…
X-Ray tips DynamoDB… Elastic Cache... AWS KMS…
- To enable X-ray: - DynamoDB is serverless and is per region - Always read the question carefully to - GenerateDataKey
- EC2: user data script - Use BatchWriteItems and BatchReadItems determine whether the question contains - Returns both plaintext
- ECS: create docker instance with when batching operation is required for ‘highly available’ or ‘multi-threaded’ and encrypted copy of
X-ray performance reason - In general, Elastic Cache is an easy way to data key
- Beanstalk: enable x-ray inside - Use TransactWriteItems when ACID is improve performance when workload reads a - GenerateDataKeyPlainText
.ebexensions/xray-daemon.config required (All or nothing) lot of data from database and query is - Returns plaintext copy of
option_settings: - Use atomic counters when you want to expensive. data key
aws:elasticbeanstalk:xray: implement auto increment - Remember the followings: - Use client-side encryption library
XRayEnabled: true - Use conditional write when you want to update - Write through cache: Whenever - (AWS Encryption SDK) to encrypt
- Annotations: key-value pairs data that can be database only when certain conditions are met data is updated, the cache is data using plaintext key. The output is
queried via filter expression in X-ray - Projection expression allows scan/query to updated encrypted data key and encrypted
- Metadata: Similar to annotations without the return desired attributes instead of whole table - Lazy loading: Only cache on output. Remove the plain text key
query/searchable functionality - Use DynamoDB streams for you need to react demand from memory.
- Segments/Subsegments: to CUD operations, such as auditing, writing - Use AWS SDK to decrypt the data
- Allows call graph to be more data to another dynamo db, etc.. key. The data key becomes a plain
detailed by exposing inner call - Use parallel scan to improve scanning text file. Then use client side
graphs performance if there is enough read capacity encryption library to decrypt the
- GetTraceSummaries: Fetch trace summaries - Use page size and max items to control the AWS KMS encrypted data using the plain text
that contains trace ids and annotations number of rows that are read at a time (and to - Key management system (crypto) data key. Remove the plain text key
- BatchGetTraces: Fetch trace details from the avoid timeouts in the AWS CLI) - Types from memory.
trace id. Contains segment documents. - Use TTL to save space/costs when the objects - AWS Keys Others
- Remember: can be deleted after certain period of time. - Managed by AWS for - Encrypt: Encrypt data smaller than
- X-ray is used for troubleshooting - DynamoDB supports provisioned and on AWS services. 4kb. For anything larger, use
and not logging. demand throughput. - Rotated every 3 years envelope encryption.
- ReturnConsumedCapacity can be passed in - Customer managed Keys
DynamoDB tips the write request to get number of WCU used. - KMS keys in AWS
- Serverless NOSQL database - INDEXES: Include indexes
- Local Secondary Index
managed by user Cognito
- TOTALS: Just the main table - Rotated every 1 year
- Same key as primary but with User pools
and can be configured - Use for sign in and sign out
different sort key
- Symmetric functionality
- Can only be defined when table is
- 256 bit encryption key that never - Can integrate with social identity
created
- Global Secondary Index Elastic Cache leaves AWS unencrypted. provider (idP) such as Facebook
- Both supports data partitioning - To use, call AWS KMS - Default login page
- Different key, sory key can be
- Distribute data among multiple - The same key is used for - Only logo can be changed
anything
nodes to improve scalability encryption and decryption. Identity pools (federated identities)
- Query supports eventual
- MemCache - Asymmetric: - Provides temp credentials for
consistency only
- Multi-threaded: Can leverage - Pair of public/private keys accessing AWS services
- Read and Write capacity should be
multi-cores to handle more - Public is used for decryption Cognito sync:
>= table, otherwise you will hit the
requests outside of AWS (also within) - Sync user profiles across multiple
provisioned throughput exception
- Should be preferred as it is simpler - Private is used for encryption devices
- Use DAX to improve read performance to
unless availability is a factor. inside AWS
microseconds. Note that DAX costs $ and
- Redis - CloudHSM: hardware-based security module
lookout for specific keywords in the exam such
- Supports replication-> highly that allows user to generate and use keys on
as cost-effective (which means DAX should be
available the AWS Cloud. If the questions mentions
ruled out in favor of something else)
‘hardware’, the answer will be this.
Cloudformation SQS CloudWatch… CodeDeploy
- StackSets: Share stack across multiple - Always use long polling to save costs - Namespace: Container for cloudwatch - On premise
accounts - Use message deduplication id in the provider metrics. eg . AWS/<services> - In place deployment
- To prevent accidental deletion, use termination to avoid duplicates. Any duplicates sent within - Dimensions:
protection 5 minute window will be ignored - name/value pair that identifies a - EC2/ECS/Lambda
- To import value exported by another stack in - If a function execution time is longer than the metric - In place deployment
outputs, use fn::ImportValue message visibility timeout, the message that is - You can find metrics to a specific - Blue/Green
- To package and deploy, currently being consumed will be visible to ec2 instance using InstanceId - Canary
- aws coudformation package other consumers. To avoid this situation, set dimension. - Linear
- aws cloudformation deploy visibility timeout to longer period - Useful metrics to remember: - All at once
- Cfn-init: Run scripts, install packages, start - Use SQL delay to delay the message being - Latency: How slow is API overall
services, etc.. visible to consumers after it is created. This is - IntegrationLatency: How slow is
useful for situation where you need to delay the backend (e.g lambda) Code Commit
sending message so that something - CacheHitCount - Similar to GitHub. If you understand GitHub,
SAM happened before the message is sent (e.g - CacheMissCount you will understand GitCommit
- Framework for building serverless application payment is processed in another system) - Can be accessed
- Consists of - SQS FIFO Beanstalk - using IAM User with the right
- SAM template specificaiton - Exactly once processing - Best for deploying scalable web apps written permissions. User will need to
- AWS SAM CLI - Preserves order in Java,Go, .Net, PHP, NodeJS, Ruby and associate public key with their IAM
- Resources - SQS Standard Docker and resources are automatically User. In addition, user will need to
- AWS::Serverless::Api - At least once processing managed ( deployment, capacity provisioning, setup GitCredentialHelper to use
- AWS::Serverless::Application load balancing, auto scaling and health AWS Creds.
- AWS::Serverless::Function CloudWatch monitoring) - Git credentials: HTTPS connection
- AWS::Serverless::HttpApi - Default time period: 5 min - Configs are stored in .ebextension folder using username and password
- AWS::Serverless::LayerVersion - To increase interval to every 1 min, use - Beanstalk worker environments are great for
- AWS::Serverless::SimpleTable detailed monitoring handling background tasks. Can be configured CodeBuild
- AWS::Serverless::StateMachine - To increase interval to under minutes, use to fire via SQS using daemon. Alternatively, it - a fully managed continuous integration se
- Commands high-resolution metric can be triggered using CRON via cron.yaml that compiles source code,
- AWS SAM init - Ops: - Deployment: runs tests, and produces software
- Init a SAM project - PutMetricData packages that are ready to deploy.
- AWS SAM build - Creates or updates - Similar to Bamboo build or Jenkins
- Build a SAM project metrics - Config is named Buildspec.yml
- AWS SAM deploy - PutMetricAlarm:
- Deploy a SAM project - Creates or updates ECS
- Cloudformation can use transform command alarm - Container orchestration service that run
to take template written in AWS SAM Syntax - Alarms: dockers applications
Types Capacity Rollback Speed
and transform it to cloud formation compliant - Period: Granularity of period reduction impact - Task definition (configures docker)
template. - Evaluation period: last number of - To use X-ray, create docker container
periods to evaluate All at once Full Full Fastest with x-ray SDK
- Datapoints to alarm: Number of Rolling Minor Minor Fast
- Cluster query language: group containers
data points within evaluation by expressions
period to trigger the alarm. Rolling with None Same as rolling Slow - Tasks Placement strategy:
- Dashboard: batches - Random: Tasks placed
- Allows user to create dashboard Immutable None None Slowest randomly while still respecting
for monitoring resources across the constraints.
region - Binpack: Reduce #instances
- Spead: Spread evenly
Kinesis Stream I AM I AM… Others…
- Shards You then call aws sts assume-role to - AWS SWF
- Cold shards: - Role: An IAM identity that has specific assume the role - Orchestrate workflow. Eg.
- Underutilized permissions. Similar the user but can aws sts assume-role --role-arn business process
- Suggest to merge be attached to "arn:aws:iam::123456789012:role/examp - Markers can be used to record
(decrease capacity) service/person/applications le-role" --role-session-name events for application specific
- Hot shards: - Principal: Person or application that AWSCLI-Session purposes.
- Overutilized can make requests for an action on - AWS StepFunctions
- Suggest to split AWS resource AWS STS (Security token service) - Runs serverless workflows
(increase capacity) - Policies: Permission(s) for an action. - AssumeRole - To pass output as input to the next
- Performance: Eg S3:PutObject - Used for AWS users or roles with step, use ResultPath
- #shards = #compute instances - Identify: Allow/deny existing creds. - Parameter store vs Secrets manager
- Data is kept in the shards for only 24 hours actions on resource X. - AssumeRoleSAML - If the question is about RDS and
Attaches to an identity - Used with SAML rotations of secrets are required,
S3/Cloudfront tips - Resource: Attaches to a - AssumeRoleWithWebIdentity the answer is always Secrets
- To encrypt data at rest, use default encryption resource (eg. s3, SQS, - GetSessionToken: manager
- To ensure data is encrypted at rest when VPC endpoints, etc.) - Used with MFA - Keys can be in hierarchical form:
uploading, - GetFederationToken - foo/bar, foo/hello, foo
- Appropriate bucket policy to deny - Troubleshooting - Used for custom integration - Question about customers with multiple
s3 action when condition To diagnose policy/permission issue, - projects in AWS.
x-amz-server-side-encryption is use IAM Policy Simulator Delegating access between 2 accounts. Eg user in - Solution: Splitting projects by
neither true nor AES256 - How does assume role work? account dev access s3 bucket in prod accounts and then use
- make sure - On prod account, create I AM role and specify consolidated billing
x-amz-server-side-encryption is Define trust policy allows a principal dev account as trusted entity - Lambda@Edge is good for use case where
set to true in header to assume a role. - Set policy that will grant access to S3 for the I you have global users and you want to run
- Transferring large data in S3 { AM role above lambda function closer to the user for
- Use S3 content transfer "Version": "2012-10-17", "Version": "2012-10-17", performance reason. E.g authentication
acceleration where possible when "Statement": { "Statement": [ workflow
name is DNS compliant "Effect": "Allow", {
- AWS Cloud9 is an integrated IDE that allows
"Principal": { "AWS": "Effect": "Allow",
- If name is not DNS compliant "Principal": {"AWS":DEV-ACCOUNT-ID}, you to write, run and debug your code in
"arn:aws:iam::123456789012:root" },
(contains dots), use Multi-Upload "Action": "sts:AssumeRole" "Action": [ browser
- If uploading encrypted file via multi-upload } "s3:*" - Question about ECS cluster where instances
- Make sure user have aws-decrypt } ], are intermittently failing health check
permission, otherwise you will get "Resource": - Solution: Increase the healthcheck
error Create role and specify trust policy: "arn:aws:s3:::productionapp"
period
}
- To allow only certain users from accessing url aws iam create-role } - Question about ECS cluster where many
(members, eg.), use pre-signed url --role-name example-role - On dev account, create policy to assume IAM instances are launched too soon and then
- To improve performance for global audience, --assume-role-policy-document role in prod. Attach that policy to the user. scaled back due to over-provisioning
use cloudfront file://example-role-trust-poli { - Solution: Use cool down (for
- To enable SSL for Cloudfront cy.json "Version": "2012-10-17", simple scaling policies), otherwise
- Viewer-protocol-policy "Statement": { warm up can also be used since
- Https only You can attach a policy to a role "Effect": "Deny", instance that is warming up is not
- Http to https using attach-role-policy "Action": "sts:AssumeRole",
added to the auto-scaling group.
"Resource":
- Origin protocol policy aws iam attach-role-policy "arn:aws:iam::PRODUCTION-ACCOUNT-ID:role/Up - EC2
- Https only --role-name example-role dateApp" - Metadata
- To control access at object level, use ACL --policy-arn } - Allows user to retrieve
"arn:aws:iam::aws:policy/Amazo } private and public IP
nRDSReadOnlyAccess" - User data: Run script
General tips Best practices….
- Always pay attention to the following keywords as that will - To optimize performance for workload involving
dictate different solutions lambda functions and an immediate response is
- Availability not required, consider using async lambda
- Costs functions to leverage parallelism
- Performance - Security:
- E.g DAX is the fastest performing option but may be - Principles of least privilege
more costly than changing code to use query - Never ever use root account access keys for
instead of scan. etc.. every-day tasks (better if its deleted)
- For hard questions, sometimes AWS will intentionally give - Https please
misleading answers
- Rule out the least likely by scrutinizing each one
- Whatever remains is probably the answer
Best practices
- Development with AWS services
- In general, Serverless > Beanstalk >
ECS > EC2
- In AWS’s world, DynamoDB > RDS
- Deployment
- Always prefer blue/Green deployment to
avoid capacity reduction and impact to
customers
- Monitoring / Troubleshooting
- X-ray SDK for troubleshooting your
AWS applications, especially if you rely
on many AWS services
- AWS CloudTrail for logging/auditing
- AWS CloudWatch for monitoring system
metrics
- Refactoring:
- RDS: Use elastic cache or read replicas
to improve read performance.
- DynamoDB: Always use query (with
global or secondary indexes). Use
pagination to limit amount of data being
transferred. DAX should be used if costs
is not a factor.
- Use retry with exponential backoffs to
avoid overloading a server that is under
load.
- Always use optimistic locking on
situation where there are multiple
updates on the same row

You might also like