You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+
## Project Overview
6
+
7
+
Terraform module that deploys Plex Media Server on AWS using EC2 Spot Instances with S3-backed media storage (s3fs-fuse) and Docker. Runs Plex as a systemd-managed Docker container on Amazon Linux 2.
8
+
9
+
## Common Commands
10
+
11
+
```bash
12
+
# Format all Terraform files
13
+
terraform fmt -recursive
14
+
15
+
# Validate configuration
16
+
terraform validate
17
+
18
+
# Run all pre-commit hooks (formatting, validation, docs, linting)
19
+
pre-commit run -a
20
+
21
+
# Generate/update README documentation tables
22
+
terraform-docs markdown . --lockfile=false
23
+
```
24
+
25
+
There are no automated tests. Validation is done via `terraform validate` and `tflint` through pre-commit hooks.
26
+
27
+
## Architecture
28
+
29
+
The module provisions a complete single-instance Plex deployment:
30
+
31
+
-**VPC** (`vpc.tf`): `10.0.0.0/16` CIDR (stored as `local.vpc_cidr`), 3 public subnets only
32
+
-**EC2** (`autoscaling.tf`): Single Spot instance via ASG with rolling refresh, Amazon Linux 2 AMI
33
+
-**Storage** (`s3.tf`): Single S3 storage bucket with folder-based library prefixes + one DB backup bucket, all using INTELLIGENT_TIERING
34
+
-**IAM** (`iam.tf`): Instance profile with S3 and SSM access
35
+
-**Security** (`sg.tf`): Port 32400 open for Plex access
36
+
-**Secrets** (`ssm.tf`): Plex claim token stored as SecureString in SSM Parameter Store
37
+
-**Bootstrap** (`templates/userdata.sh`): Installs Docker/s3fs, mounts S3 buckets, starts Plex container as systemd service
38
+
39
+
Subnet CIDRs are computed directly in `vpc.tf` using `cidrsubnets()`. VPC CIDR is defined once in `locals.tf`.
-**Code ownership**: `@zahorniak` is default CODEOWNER.
54
+
55
+
## Coding Guidelines
56
+
57
+
- Don't specify Terraform/AWS defaults explicitly (e.g., gp3 baseline IOPS, `protect_from_scale_in = false`). Only set values that differ from defaults.
58
+
-`templates/userdata.sh` uses Terraform `templatefile()` variables — never hardcode values available as variables (e.g., region).
@@ -72,10 +72,10 @@ To avoid scanning of the files in the S3 bucket (meaning additional S3 api reque
72
72
| <aname="input_force_destroy"></a> [force\_destroy](#input\_force\_destroy)| Force destroy the S3 bucket |`bool`|`false`| no |
73
73
| <aname="input_instance_storage_size"></a> [instance\_storage\_size](#input\_instance\_storage\_size)| Size for EC2 EBS root volume |`number`|`30`| no |
74
74
| <aname="input_instance_type"></a> [instance\_type](#input\_instance\_type)| Type of EC2 instance |`string`|`"t3a.micro"`| no |
75
-
| <aname="input_plex_claim_token"></a> [plex\_claim\_token](#input\_plex\_claim\_token)| Token to claim your plex media server. You can get this by going to https://www.plex.tv/claim.|`string`| n/a | yes |
76
-
| <aname="input_plex_libraries"></a> [plex\_libraries](#input\_plex\_libraries)| List of Plex libraries|`list(string)`| n/a | yes |
75
+
| <aname="input_plex_claim_token"></a> [plex\_claim\_token](#input\_plex\_claim\_token)| Token to claim your plex media server. You can get this by going to https://www.plex.tv/claim.|`string`| n/a | yes |
76
+
| <aname="input_plex_libraries"></a> [plex\_libraries](#input\_plex\_libraries)| List of Plex library folder names (created as prefixes inside a single S3 storage bucket)|`list(string)`| n/a | yes |
0 commit comments