%%{init: {'theme': 'base', 'look': 'classic', 'themeVariables': {'fontFamily': 'monospace', 'fontSize': '16px'}}}%%
graph LR
subgraph "Responsibility"
SaaS("SaaS: You manage<br>only usage")
PaaS("PaaS: You manage<br>apps & data")
IaaS("IaaS: You manage<br>OS, apps, &<br>data")
end
Provider(["Provider manages<br>infrastructure"]) --> SaaS
Provider --> PaaS
Provider --> IaaS
style Provider fill:#5B8C5A,stroke:#000000,stroke-width:1px,color:#ffffff
style IaaS fill:#D2562B,stroke:#000000,stroke-width:1px,color:#ffffff
style SaaS fill:#1B2A41,stroke:#000000,stroke-width:1px,color:#ffffff
style PaaS fill:#2A6F77,stroke:#000000,stroke-width:1px,color:#ffffff
Lab 7: Cloud Servers
This lab answers the comprehension questions from Chapter 7 of DO4DS (The Cloud). Lab 6 packaged the penguin model API in a Docker container on our local machine. Lab 7 moves that work to the cloud, where we rent servers and storage instead of running everything locally. The DO4DS labs get started with AWS by launching an EC2 instance, then put the penguins data and model in S3.
Comprehension questions
Going to the cloud
“What are two reasons you should consider going to the cloud?”
Two primary reasons to move to the cloud include:
- The ability to rapidly increase or decrease computing resources to match demand without investing in physical hardware (i.e., scalability)
- The cloud provider handles much of the underlying infrastructure management, such as hardware repairs, power, and cooling (i.e., reduce maintenance).
“What’s one reason you shouldn’t?”
One reason we might avoid the cloud is cost unpredictability. While we only pay for what we use, unmonitored usage or unexpected spikes in demand can lead to much higher monthly bills than anticipated.
Cloud service types
“What is the difference between PaaS, IaaS, and SaaS?”
The differences lie in how much of the technology stack we manage versus how much the provider manages:
The table below covers other differences:
| Acronym | Model | Responsibility |
|---|---|---|
| IaaS | Infrastructure as a Service | User manages OS, middleware, and apps |
| PaaS | Platform as a Service | User manages applications and data |
| SaaS | Software as a Service | User manages only usage |
“What’s an example of each that you’re familiar with?”
| Acronym | Description | Example |
|---|---|---|
| IaaS | Provides raw computing resources like virtual servers and networking. | Azure |
| PaaS | Provides a framework for developers to build and deploy apps without managing the OS. | Posit Connect Cloud |
| SaaS | Delivers finished software applications over the internet. | Teams |
AWS services
“What are the names of AWS’s services for: renting a server, filesystem storage, blob storage?”
- If you are renting a server: Amazon EC2 (Elastic Compute Cloud)
- For filesystem storage: Amazon EBS (Elastic Block Store) is the disk attached to an EC2 instance. Amazon EFS (Elastic File System) is a shared file system that many instances can mount at once.
- For blob storage: Amazon S3 (Simple Storage Service)
Setting Up AWS and S3
The DO4DS lab comes in two parts: getting started with AWS and putting the penguins data and model in S3. This book splits them into four chapters:
Getting started with AWS: create an IAM group and user, an access key, and a
dev-deployprofile for the AWS CLI on our local machine.Stand up an EC2 instance: create a key pair, a security group, and an IAM role. Then launch an Amazon Linux 2 (AL2) instance with the AWS CLI. DO4DS launches an Ubuntu instance from the Console instead. Lab 10 moves the instance to Amazon Linux 2023.
Create S3 & Push/Pull Data: create the
penguin-vetiver-model-databucket and write the Python and R models to it withpins.GitHub Actions and S3: connect GitHub to AWS with OpenID Connect (OIDC). A workflow then publishes the models to S3 on every push to the
lab07-s3branch.
I’ve put the original files in the original/ folder, and separated the labs into original, R, and Python folders. The original files from the DO4DS _labs/lab7 folder are below:
original
├── docker
│ ├── app.py
│ ├── Dockerfile
│ └── vetiver_requirements.txt
├── model-vetiver-s3.qmd
└── publish-s3.yml
2 directories, 5 files- 1
-
vetiverAPI that reads a fixed version of thepenguin_modelpin from thedo4ds-labS3 bucket (pins.board_s3()) - 2
-
Dockerfile generated by
vetiver: starts frompython:3.9and runs the API withuvicornon port 8080 - 3
-
Python packages for the API, pinned with
pip-compile - 4
-
Fits the linear regression model and writes it to the
do4ds-labS3 bucket withvetiver_pin_write() - 5
-
GitHub Actions workflow that renders and publishes the site to
gh-pageson every push tomain, with AWS access keys stored as repository secrets
Recap
The cloud is worth considering for scalability and reduced maintenance, but unmonitored usage can make costs unpredictable.
IaaS, PaaS, and SaaS differ in how much of the stack we manage. With IaaS we manage the OS, apps, and data; with PaaS we manage apps and data; with SaaS we manage only usage.
AWS’s services for renting a server, filesystem storage, and blob storage are EC2, EBS (or EFS for shared storage), and S3. The four chapters that follow launch an AL2 instance on EC2 and publish the models to S3, first by hand and then with GitHub Actions.
We’ll start by setting up IAM users and the AWS CLI in Getting started with AWS.