Deployment & Instance Management Flashcards
Elastic Beanstalk Billing
Free itself, pay for underlying instances
Elastic Beanstalk Managed Services
- Instance/OS configuration (EC2, Elastic IP, RDS master)
- Configurable deployment strategy
Elastic Beanstalk Architecture Models
- Single Instance - Dev
- LB + ASG + Standby RDS - Prod/Staging, multi AZ
- SQS + ASG - Prod, non-web, workers etc
Elastic Beanstalk Worker Setup
- Long to complete, decoupling app into two tiers
- Can be called from web-app tier through SQS
- Can define periodic tasks into cron.yaml
Elastic Beanstalk Blue/Green
- Using Route53 weighted routing
- Swap urls (DNS swap), when test v2 is done
OpsWorks
- Chef & Puppet based on-prem, helps migrate to cloud
- Linux/Windows
- Open source, cross-cloud
- Cannot manage ASG
OpsWorks Layers
Stack contains Layers
- ELB (ex ALB)
- Application Server (EC2) needs cookbook and app repository access
- Database (RDS)
AWS CodeDeploy
- Managed Service Using CodeDeploy Agent: - EC2 - ASG - ECS - Lambda
AWS CodeDeploy EC2
- appspec.yml + deployment strategy
- in place updates
- hooks for verification after each deploy phase
- Example -> half n half
AWS CodeDeploy Lambda
- Traffic shifting feature
- Pre and Post traffic hooks (lambda functions) to validate deployment (before traffic shift starts and after it ends)
- Easy & automated rollback using CW Alarms
- SAM framework natively uses CodeDeploy
AWS CodeDeploy ECS
- Facilitates Blue/Green in ECS
- Setup is within ECS service definition
- Creates new task set, traffic shifting
- If stable for x minutes, old task set terminated
CloudFormation (IaC) & ASG
- CF manages ASG only, not underlying EC2
- Can define “success conditions”, for launch of EC2 via CreationPolicy
- Can define “update strategies” for update of EC2 via UpdatePolicy
CloudFormation - Retaining Data on Deletes
- Attach DeletePolicy to resource to control CF del action
- Retain - preserve/backup (works on nested stack)
- Snapshot
- Delete - default for most except (RDS DB cluster which is Snapshot)
- To delete S3 bucket, remove contents first
CloudFormation and IAM
- Uses IAM principal permissions
- Or can assign IAM role to the stack
- To create IAM resources, need to explicitly provide capability to CF, CAPABILITY_IAM or CAPABILITY_NAMED_IAM
CloudFormation Custom Resources using Lambda
- Not yet supported in CF new aws service
- Empty content of S3 bucket
- On-prem resource
- Fetch AMI id, etc…
CloudFormation Cross Stack
- Use Outputs Export and Fn::ImportValue
- example VPC id from CF stack needed to be referenced in other stacks, e.g. EC2
CloudFormation Nested Stack
- Module, to be re-used by other parent stacks
CloudFormation - CloudFormer
- Create CF template from existing AWS resources
CloudFormation - ChangeSet
- Generate & Preview CF changes before the get applied
CloudFormation - StackSet
- Deploy a CF stack across multiple accounts and region
CloudFormation - Stack Policies
Prevent accidental deletes/updates to stack resources
Service Catalog
- Controlled env where users can deploy pre-authorised (by admins) service catalog products
- Service Catalog is set of CF templates that users can use based on their IAM permissions
- CF templates ensure resources are standardized, consistent, compliant
- Teams are aligned with Product Portfolios for IAM permissions
- Integration with self-service portals, eg ServiceNow
AWS SAM (Serverless Application Model)
- Framework for developing and deploying serverless applications
- Configuration is in YAML
- Lambda (AWS::Serverless::Function)
- DDB (AWS::Serverless::SimpleTable)
- API Gateway (AWS::Serverless:API)
- Cognito User Pools
AWS SAM Features
- Can help run Lambda, API Gateway, DDB locally
- Uses CodeDeploy for Lambda (traffic shifting)
- Leverages CloudFormation in the backend
Deployment Options
- EC2 + User Data bootstrap
- Pre-built AMI + User Data
- ASG with launch template of pre-built AMI
- CodeDeploy - application deployments
- Elastic Beanstalk, great for migration from on-prem
- In-place all at once
- Rolling upgrades (with or without additional instances)
- Immutable upgrades(new instances)
- Blue/Green
- OpsWorks
- SAM - leverage CF + CodeDeploy
AWS SSM
- Helps manage EC2 fleet or On-premise systems
- Free
- Linux and Windows
- Easily detect problems or check inventory across fleets
- Patching automation for enhanced compliance
- Automation of Actions (Shut Down, create AMIs)
- Integrates with CW metrics/dashboard, AWS Config
AWS SSM How it works
- SSM Service + SSM agents on controlled systems
- SSM Agent installed by default on Linux AMIs & some Ubuntu AMIs
- Make sure EC2 has IAM role to allow SSM actions
AWS SSM Run Command
- Script or command
- Run across resource groups (bundled instances)
- Rate Control and Error Control
- Integrated with IAM and CT
- NO need for SSH
- Results in console
AWS SSM Patch Manager Patch Types
- Linux
- AWS-{OS}DefaultPatchBaseline
- Windows
- AWS-DefaultPatchBaseline: Critical & Security Updates
- AWS-WindowsPredefinedPatchBaseline-OS
- AWS-WindowsPredefinedPatchBaseline-Applications
- Custom
AWS SSM Patch Manager Steps
- Define Patch Baseline
- Define Patch Groups (dev, test ) using tag Patch Group
- Define Maintenance Window
- Schedule, duration, patch groups and registered tasks
- Add AWS-RunPatchBaseline Run Command as part of Maintenance Window registered tasks
- Rate Control
- Monitor Patch Compliance using SSM Inventory