You're an SRE at esc bash. A batch job drops files into a directory on each host and someone is supposed to copy them off to object storage every night. Nobody remembers to. Build a small tool that provisions a backup bucket and ships every file in that directory up to S3 in one run, the kind of thing you would wire into a cron job.
Run this first. It seeds the directory of files to back up:
curl -fsSL https://raw.githubusercontent.com/Esc-Bash/project-init-scripts/main/python-for-devops/project-3/init.sh | bash
This creates /root/mission/backup/ with three files in it:
config.yaml, notes.txt, and servers.csv.
This environment has no live AWS behind boto3. Just like the boto3 topic,
your code runs against moto, a stand in that answers boto3's calls
locally. You write ordinary boto3 code and the grader runs it against the
mock, so you do not need real credentials and you should not point boto3
at a custom endpoint.
Write /root/scripts/s3backup.py. When run, it must use boto3 to:
us-east-1 region.esc-bash-backups./root/mission/backup/ into that bucket, using
each file's name as the object key (so config.yaml becomes the key
config.yaml, and so on)./root/answers/backup-report.json with this
exact shape:{
"bucket": "esc-bash-backups",
"uploaded": ["config.yaml", "notes.txt", "servers.csv"],
"count": 3
}
When you press Submit, the grader runs your script against a mocked AWS and then checks that the bucket, the objects, and the report all came out right.
Press Submit when done.
Start the lab on the right to run checks.