Skip to content

Terraform module for Plex Media Server on AWS using Spot Instances and S3 for Media Storage

License

Notifications You must be signed in to change notification settings

zahorniak/terraform-aws-plex

Repository files navigation

Terraform module for Plex Media Server on AWS using Spot Instances and S3 for Media Storage

Plex Claim Token

Get Plex Claim Token: https://www.plex.tv/claim

The Claim Token is only good for a few minutes, so it is easiest to not set this variable and let Terraform prompt you for it.

After your server is done spinning up

If the plex app cannot connect to your server

  • Go to http://{ip}:32400/web
  • Settings -> Remote Access -> Enable Remote Access
    • Check Specify Port (leave the port the same) and retry

Create Libraries

  • Go to Manage -> Libraries
    • Create libraries seleting folders within the /plex-data folder

Minimize EBS and S3 API Requests to Reduce Cost

To avoid scanning of the files in the S3 bucket (meaning additional S3 api requests and additional EBS i/o requests -> additional cost)

  • Don't set Plex to periodically scan library
  • Turn off scheduled tasks that will scan the library - I leave on the following
    • Backup database every three days
    • Optimize database every week
    • Remove old bundles every week
    • Remove old cache files every week
    • Upgrade media analysis during maintenance

Requirements

Name Version
terraform >= 1.3.7
aws >= 4.30

Providers

Name Version
aws >= 4.30

Modules

Name Source Version
plex_autoscaling terraform-aws-modules/autoscaling/aws ~> 7.7
s3_plex_db terraform-aws-modules/s3-bucket/aws ~> 3.3
s3_plex_storage terraform-aws-modules/s3-bucket/aws ~> 3.3
vpc terraform-aws-modules/vpc/aws ~> 5.9

Resources

Name Type
aws_iam_policy.plex_server resource
aws_security_group.plex_admin resource
aws_ssm_parameter.plex_claim_token resource
aws_ami.plex data source
aws_availability_zones.main data source
aws_iam_policy_document.plex_ec2 data source

Inputs

Name Description Type Default Required
aws_region AWS Region string "eu-central-1" no
force_destroy Force destroy the S3 bucket bool false no
instance_storage_size Size for EC2 EBS root volume number 30 no
instance_type Type of EC2 instance string "t3a.micro" no
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
plex_libraries List of Plex libraries list(string) n/a yes

Outputs

No outputs.