## Notes
Rewriting [[AWS Certified Developer Associate Exam Tips]] to review what I wrote
## Deployment
- Be familiar with [[AWS Elastic Beanstalk]] to deploy applications
- Serverless with Lambda
- Deploy with CodePipeline, CodeBuild, and CodeDeploy
### CodeBuild
- It's a fully-managed build service.
- Can build from CodeCommit, GitHub, BitBucket, etc
- Local debugging is possible
- Configure with `buildspec.yaml`
```yaml
#buildspec.yaml
version: 1.0
environment_variables:
plaintext:
JAVA_HOME: "..."
phases:
install:
commands:
- echo Downloading JUnit JAR file
- mkdir lib
- wget http://central.maven.org/maven2/junit/...
pre_build:
commands:
- echo Creating directories
- mkdir build
build:
commands:
- echo Build started on `date`
- ant
post_build:
commands:
- echo Build completed on `date`
artifacts:
files:
- build/jar/HelloWorld.jar
```
### CodeDeploy
- Minimize downtime with a deployment strategy
- Centralized control
- Iteratively release new features
- Deployment types: in-place, rolling, blue-green
- Deployment configurations: *OneAtATime*, *HalfAtATime*, *AllAtOnce*
- Can install `CodeDeploy` on EC2 and on-prem
- Use `appspec.yaml`
```yaml
# appspec.yaml
version: 0.0
on: linux # or windows
files:
- source: config.txt
destination: /webapps/config
- source: source
destination: /webapps/myApp
hooks:
BeforeInstall:
- location: scripts/unzipResourceBundle.sh
- location: scripts/unzipDataBundle.sh
AfterInstall:
- location: scripts/runResourceTests.sh
timeout: 100
ApplicationStart:
- location: scripts/runFunctionalTests.sh
timeout: 3600
ValidateService:
- location: scripts/monitorService.sh
timeout: 3600
runas: codedeployuser
```
### CodePipeline
- Manual approval step
- Pipeline actions
- Source: `CodeCommit`, `GitHub`
- Build & Test: `CodeBuild`, `Jenkins`
- Deploy: [[CodeDeploy]], [[CloudFormation]], [[Elastic Beanstalk]], [[OpsWorks]]
- Invoke: specify custom function to run like [[AWS Lambdas]]
- Approval: Publish [[SNS]] topic for manual approval
### SAM
- Uses *CloudFormation* under the hood
- Separate `sam` CLI vs `aws` CLi
### Lambda
Deploy *Lambda* in two ways
- `.zip` file that includes application code and dependencies--needs to be uploaded to [[S3]]
- Dockerized image uploaded to [[ECR]]
### Elastic Beanstalk
- Handles deployment, scaling, capacity provisioning, load balancing, monitoring
- Simple from the CLI or Console
- Create code and launch it
- Create a role with `beanstalk-ec2` privileges
- Example app launches
- EC2 instance
- EC2 security group
- S3 bucket
- CloudWatch alarms
- AWS CloudFormation stack
- Domain name