AWS: CDA Flashcards
(172 cards)
What is Elastic Beanstalk?
- Developer-centric view of deploying an app on AWS
- Fully managed service
- Handles capacity provisioning, load balancing, scaling, monitoring
- Free service but underlying AWS resources will have costs involved
What are the components involved in Elastic Beanstalk?
- Application
- Collection of components
- Application version
- Iteration of app code
- Environment
- Collection of AWS resources running an app version
- Env tiers to support diff types of apps
- Multiple env can be created ie. dev/prod
What are the use cases for the different environment tiers?
- Web server environment tier
- Website
- Web app
- Web app serving HTTP requests
- Worker environment tier
- Processing long-running workloads on demand
- Perform tasks on a schedule
List the different deployment options available for Elastic Beanstalk
- All-at-once deployment
- Fastest
- Instances are down during update
- No additional cost
- Rolling deployment
- Zero downtime
- Deployment time depends on number of instances
- No additional cost
- Rolling deployment with additional batches
- Zero downtime
- Deployment time depends on number of instances
- Small additional cost
- Immutable deployment
- Zero downtime
- Longest deployment
- High cost, double capacity
- Quick rollback in case of failure
- Blue/green deployment
- Zero downtime
- Traffic-splitting deployment
- Zero downtime
- Quick rollback in case of failure
How do rolling deployments work?
- Apps running below capacity with set bucket size
- Instances in the bucket will be down during update
- Once instances in the bucket are updated, process repeats for next bucket (batch of instances)
How does rolling deployments with additional batches work?
Deployments
- App running at capacity with set bucket size
- New instances created with upgraded version
- Existing instances go through rolling deployments
- After rolling deployment is complete, the newly-created instances will be terminated
How does blue/green deployments work?
- Create a new environment (green) where new version is deployed
- Easy rollback to old environment (blue) if issues arise
How do traffic-splitting deployments work?
Deployments
- Used for canary testing
- New app version deployed to temp ASG with same capacity
- Small % of traffic sent to temp ASG for a configurable amount of time
- New instances migrated from temp to original ASG and then old version is terminated
- Automated rollback if issues arise
What is the lifecycle policy for Elastic Beanstalk?
- A configurable policy to limit no. of app versions to retain for future deployments
- Limit by count
- Limit by age
- Must be enabled first to configure policy
What happens under the hood for Elastic Beanstalk?
- Relies on CloudFormation
- CloudFormation is infra as code
- Used to provision other AWS services
What is Elastic Beanstalk cloning?
- Clone an environment with exact same configuration
- All resources and config are preserved
- After cloning an environment, you can modify settings
- Useful for deploying a “test” version of your app
What is API Gateway?
- Serverless service to manage and secure APIs
- A single interface for all microservices
- Use API endpoints with various resources
- Apply forwarding and transformation rules at API Gateway level
What are some features of API Gateway?
Development
- Support websocket protocols
- Transform and validate requests/responses
- Handle request throttling
- Cache API responses
- Handle API versioning
- Handle different environments
- Handle security
What are the different endpoint types for API Gateway?
- Edge-optimised (default)
- Requests routed through CloudFront Edge locations to improve latency
- API Gateway still only lives in one region
- Regional
- For clients within same region
- Could be manually combined with CloudFront
- Private
- Only accessed from your VPC using interface VPC endpoint
- Use resource policy to define access
What are the user authentication strategies available for API Gateway?
- IAM roles
- Useful for internal applications
- AWS Cognito
- Useful for external users
- Custom authoriser (your own logic via Lambda function)
How can you have security with your own custom domain name by integrating API Gateway with ACM?
- If using edge-optimised endpoint, certificate must be in us-east-1
- If using regional endpoint, certificate must be in API Gateway region
- Must setup CNAME or A-alias record in Route 53
What are stage variables in API Gateway?
Development
- Similar to environment variables
- Used to update frequently changing config values
- If used in Lambda functions, they are passed to the “context” object
What are the use cases for stage variables in API Gateway?
- They can be used in:
- Lambda function ARN
- HTTP endpoint
- Parameter mapping templates
- Use cases:
- Configure HTTP endpoints that the stages talk to (dev, test, prod)
- Pass config parameters to Lambda functions through mapping templates
How to perform canary deployments in API Gateway?
- Usually done with prod
- Choose % of traffic the canary channel receives
- Metrics/logs are separate for better monitoring
- Stage variables can be overridden for canary deployments
- Once canary deployments have been tested and if all good, they can be promoted to entire stage
What are the different integration types for API Gateway?
- Mock integration type
- API Gateway returns a response without sending a request to backend
- HTTP/AWS services
- Both integration req and res must be configured
- Setup data mapping using mapping templates for req and res
- AWS proxy integration type
- Incoming req from client is the input to Lambda
- Lambda function is responsible for logic of req/res
- No mapping template/headers/query params are passed as arguments
- HTTP proxy integration type
- HTTP req is passed to backend
- HTTP res from backend is forwarded by API Gateway
- No mapping templates
- Optionally add HTTP headers if needed eg. API key
What are mapping templates in API Gateway?
- Templates used to modify req/res
- Rename/modify query string params
- Modify body content
- Add headers
- Filter result output
- To set the template, the content-type must be set to either application/json or application/xml
- Not used for proxy integration types
How can API Gateway utilise request validation?
- Importing Open API definitions
- The spec is used to verify if req corresponds to proper schema before proceeding with req
- If validation fails, API Gateway immediately fails req
- Reduces unnecessary calls to backend
How does caching work in API Gateway?
- Caching reduces number of calls to backend
- API Gateway will first check cache
- If cache miss, call backend
- Default TTL is 300s
- Cache is expensive - makes sense for prod but may not make sense for dev/test
What is the difference between latency vs integration latency in API Gateway?
- Integration latency
- Time between when API Gateway relays req to backend and receives a response from backend
- Latency
- Time between when API Gateway receives req from client and when it returns response to client
- Includes integration latency and other API Gateway overhead