{"id":14008260,"url":"https://github.com/r7kamura/mastodon-terraform","last_synced_at":"2025-07-24T03:32:27.660Z","repository":{"id":66264706,"uuid":"88563114","full_name":"r7kamura/mastodon-terraform","owner":"r7kamura","description":"Boilerplate for running Mastodon on AWS using Terraform and CircleCI.","archived":true,"fork":false,"pushed_at":"2017-05-31T06:15:56.000Z","size":240,"stargazers_count":84,"open_issues_count":5,"forks_count":40,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-05-01T23:21:45.780Z","etag":null,"topics":["docker","mastodon","terraform"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/r7kamura.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-04-18T00:25:56.000Z","updated_at":"2024-05-01T23:21:45.780Z","dependencies_parsed_at":"2023-09-24T13:39:56.685Z","dependency_job_id":null,"html_url":"https://github.com/r7kamura/mastodon-terraform","commit_stats":{"total_commits":149,"total_committers":4,"mean_commits":37.25,"dds":0.03355704697986572,"last_synced_commit":"b5446ae293f0e0eeb23e17238466b0fa26c37ada"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fmastodon-terraform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fmastodon-terraform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fmastodon-terraform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r7kamura%2Fmastodon-terraform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r7kamura","download_url":"https://codeload.github.com/r7kamura/mastodon-terraform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227410556,"owners_count":17774769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","mastodon","terraform"],"created_at":"2024-08-10T11:01:30.910Z","updated_at":"2024-11-30T19:30:55.983Z","avatar_url":"https://github.com/r7kamura.png","language":"HCL","funding_links":[],"categories":["HCL"],"sub_categories":[],"readme":"# mastodon-terraform\n\nBoilerplate for running [Mastodon](https://github.com/tootsuite/mastodon) on AWS using [Terraform](https://github.com/hashicorp/terraform) and [CircleCI](http://circleci.com/).\n\n```\n┌---------------┐\n|  Web Browser  |\n└---------------┘\n▲               ▲\n|               |\n(HTTPS)         (WSS)\n|               |\n▼               |\n┌------------┐  |\n| CloudFront |  |\n└------------┘  |\n▲               |\n|               |\n(HTTP)          |\n|               |\n▼               ▼\n┌---------------┐\n|      ALB      |\n└---------------┘\n▲               ▲\n|               |\n(HTTP)          (WS)\n|               |\n▼               ▼\n┌------------------------┐\n| ┌-Docker-┐ ┌-Docker--┐ |\n| |  Puma  | | Express | |\n| └--------┘ └---------┘ |\n| ┌-Docker--┐            |\n| | Sidekiq |     EC2    |\n| └---------┘            |\n└------------------------┘\n▲                  ▲\n|                  |\n▼                  ▼\n┌----------------┐ ┌-------------┐\n| ┌------------┐ | |  ┌-------┐  |\n| | PostgreSQL | | |  | Redis |  |\n| └------------┘ | |  └-------┘  |\n|       RDS      | | Elasticache |\n└----------------┘ └-------------┘\n```\n\n## Usage\n\n1. Fork this repository\n1. Enable CircleCI integration\n1. Set environment variables on CircleCI\n1. Run CircleCI job to create resources on AWS\n1. Build and push mastodon docker image via [mastodon-docker](https://github.com/r7kamura/mastodon-docker)\n1. Run `rails db:setup` by running custom ECS task on AWS console\n\n## Required environment variables\n\n### AWS_ACCESS_KEY_ID\n\nAWS IAM User access key ID for Terraform.\n\ne.g. `ABCDEFGHIJKLMNOPQRST`\n\n### AWS_DEFAULT_REGION\n\nAWS region that the resources will be located in.\n\ne.g. `ap-northeast-1`\n\n### AWS_SECRET_ACCESS_KEY\n\nAWS IAM User secret access key for Terraform.\n\ne.g. `abcdefghijklmnopqrstuvwxyz0123456789/+AB`\n\n### AWS_S3_BUCKET_TERRAFORM_STATE_NAME\n\nThe domain that your terraform state file will be stored.\nTo run Terraform from CircleCI, you need to prepare a private AWS S3 bucket to store your terraform state file.\n\ne.g. `your-s3-bucket-name`\n\n### AWS_S3_BUCKET_TERRAFORM_STATE_KEY\n\nWhere to locate the terraform state file on the specified AWS S3 bucket.\n\ne.g. `terraform.tfstate` (recommended)\n\n### TF_VAR_aws_s3_bucket_name\n\nA valid S3 bucket name for uploading files (e.g. user profile images).\n\ne.g. `my-mastodon`\n\n### TF_VAR_mastodon_s3_cloudfront_host\n\nThe domain for the CloudFront distribution where uploaded files will be provided from.\n\ne.g. `cdn.example.com`\n\n### TF_VAR_mastodon_db_pass\n\nDatabase password.\n\ne.g. Generate a long random value like this:\n\n```bash\nruby -r securerandom -e \"puts SecureRandom.hex(64)\"\n```\n\n### TF_VAR_mastodon_docker_image_tag\n\nMastodon Docker image tag to detect which image to be deployed on ECS.\nIf you are using [mastodon-docker](https://github.com/r7kamura/mastodon-docker) to build and push it to ECR,\nthe CircleCI build number will be the Docker image tag.\n\ne.g. `123`\n\nNote: this variable is not required at the 1st time because we need to create ECR repository before building Mastodon Docker image.\n\n### TF_VAR_mastodon_docker_image_tag_rails_db_migration\n\nMastodon Docker image tag to detect which image to be deployed on ECS for `db:migrate` task.\nWhy this value exists is because sometimes you may want to apply database migration before deploying new revision of application.\n\ne.g. `124`\n\nNote: this variable is not required at the 1st time because we need to create ECR repository before building Mastodon Docker image.\n\n### TF_VAR_mastodon_local_domain\n\nThe domain that your Mastodon instance will run on.\n\ne.g. `mastodon.example.com`\n\n### TF_VAR_mastodon_otp_secret\n\nOne-time password secret\n\ne.g. Generate a long random value like this:\n\n```bash\nruby -r securerandom -e \"puts SecureRandom.hex(64)\"\n```\n\n### TF_VAR_mastodon_secret_key_base\n\nThe secret key base.\n\ne.g. Generate a long random value like this:\n\n```bash\nruby -r securerandom -e \"puts SecureRandom.hex(64)\"\n```\n\n## Optional environment variables\n\n### TF_VAR_aws_acm_certificate_arn\n\nIf you want to use HTTPS,\ncreate free SSL certificate for your domain on Amazon Certificate Manager on us-east-1 region,\nthen set its ARN to this environment variable.\n\ne.g. `arn:aws:acm:us-east-1:123456789012:certificate/12345678-90ab-cdef-1234-567890abcdef`\n\n### TF_VAR_aws_acm_certificate_arn_for_alb\n\nFor using secure WebSocket connection,\ncreate free SSL certificate for your domain on Amazon Certificate Manager on your region,\nthen set its ARN to this environment variable too.\n\ne.g. `arn:aws:acm:ap-northeast-1:123456789012:certificate/12345678-90ab-cdef-1234-567890abcdef`\n\n### TF_VAR_aws_db_instance_mastodon_instance_class\n\nAWS RDS DB instance class.\n\ndefault: `db.t2.micro`\n\nFYI: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html.\n\n### TF_VAR_aws_ecs_task_definition_mastodon_node_streaming_memory\n\nMemory size for node_streaming ECS task.\n\ndefault: `300`\n\n### TF_VAR_aws_ecs_task_definition_mastodon_rails_db_migration_memory\n\nMemory size for rails_db_migration ECS task.\n\ndefault: `300`\n\n### TF_VAR_aws_ecs_task_definition_mastodon_rails_db_set_up_memory\n\nMemory size for rails_db_set_up ECS task.\n\ndefault: `300`\n\n### TF_VAR_aws_ecs_task_definition_mastodon_rails_mastodon_make_admin_memory\n\nMemory size for rails_mastodon_make_admin_memory ECS task.\n\ndefault: `300`\n\n### TF_VAR_aws_ecs_task_definition_mastodon_rails_puma_memory\n\nMemory size for rails_puma ECS task.\n\ndefault: `300`\n\n### TF_VAR_aws_ecs_task_definition_mastodon_rails_sidekiq_memory\n\nMemory size for rails_sidekiq ECS task.\n\ndefault: `300`\n\n### TF_VAR_aws_elasticache_cluster_node_type\n\nAWS Elasticache Cluster node type.\n\ndefault: `cache.t2.micro`\n\nFYI: https://aws.amazon.com/jp/elasticache/pricing/.\n\n### TF_VAR_aws_launch_configuration_mastodon_instance_type\n\nAWS EC2 instance type.\n\ndefault: `t2.micro`\n\nFYI: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html.\n\n### TF_VAR_mastodon_administrator_name\n\nAdministrator user name for the `mastodon_rails_mastodon_make_admin` ECS task.\n\n### TF_VAR_mastodon_aws_access_key_id\n\nAWS IAM user access key ID for Rails to access to AWS API.\n\n### TF_VAR_mastodon_aws_secret_access_key\n\nAWS IAM user secret access key for Rails to access to AWS API.\n\n### TF_VAR_mastodon_db_name\n\nDB name.\n\ndefault: `mastodon`\n\n### TF_VAR_mastodon_db_user\n\nDB user name.\n\ndefault: `root`\n\n### TF_VAR_mastodon_default_locale\n\nDefault locale.\n\ndefault: `en`\n\n### TF_VAR_mastodon_email_domain_blacklist\n\nEmail domain blacklist.\n\n### TF_VAR_mastodon_email_domain_whitelist\n\nEmail domain whitelist.\n\n### TF_VAR_mastodon_node_streaming_api_base_url\n\nThe base URL of Streaming API endpoint.\n\ne.g. `https://mastodon-streaming.example.com:4000`\n\n### TF_VAR_mastodon_node_streaming_cluster_num\n\ndefault: `1`\n\n### TF_VAR_mastodon_single_user_mode\n\nShould the instance run in single user mode? (Disable registrations, redirect to front page)\n\ndefault: `false`\n\n### Others\n\n- `TF_VAR_mastodon_paperclip_root_path`\n- `TF_VAR_mastodon_paperclip_root_url`\n- `TF_VAR_mastodon_paperclip_secret`\n- `TF_VAR_mastodon_prepared_statements`\n- `TF_VAR_mastodon_smtp_auth_method`\n- `TF_VAR_mastodon_smtp_delivery_method`\n- `TF_VAR_mastodon_smtp_domain`\n- `TF_VAR_mastodon_smtp_enable_starttls_auto`\n- `TF_VAR_mastodon_smtp_from_address`\n- `TF_VAR_mastodon_smtp_login`\n- `TF_VAR_mastodon_smtp_openssl_verify_mode`\n- `TF_VAR_mastodon_smtp_password`\n- `TF_VAR_mastodon_smtp_port`\n- `TF_VAR_mastodon_smtp_server`\n\n## Resources\n\nThis boilerplate will create the following resources:\n\n- module.mastodon.aws_alb_listener.mastodon_node_streaming:\n- module.mastodon.aws_alb_listener.mastodon_rails_puma:\n- module.mastodon.aws_alb_target_group.mastodon_node_streaming:\n- module.mastodon.aws_alb_target_group.mastodon_rails_puma:\n- module.mastodon.aws_alb.mastodon:\n- module.mastodon.aws_autoscaling_group.mastodon:\n- module.mastodon.aws_cloudfront_distribution.mastodon:\n- module.mastodon.aws_cloudwatch_log_group.mastodon:\n- module.mastodon.aws_db_instance.mastodon:\n- module.mastodon.aws_db_parameter_group.mastodon:\n- module.mastodon.aws_db_subnet_group.mastodon:\n- module.mastodon.aws_ecr_repository.mastodon:\n- module.mastodon.aws_ecs_cluster.mastodon:\n- module.mastodon.aws_ecs_service.mastodon_node_streaming:\n- module.mastodon.aws_ecs_service.mastodon_rails_puma:\n- module.mastodon.aws_ecs_service.mastodon_rails_sidekiq:\n- module.mastodon.aws_ecs_task_definition.mastodon_node_streaming:\n- module.mastodon.aws_ecs_task_definition.mastodon_rails_db_migration:\n- module.mastodon.aws_ecs_task_definition.mastodon_rails_db_set_up:\n- module.mastodon.aws_ecs_task_definition.mastodon_rails_puma:\n- module.mastodon.aws_ecs_task_definition.mastodon_rails_sidekiq:\n- module.mastodon.aws_elasticache_cluster.mastodon:\n- module.mastodon.aws_elasticache_subnet_group.mastodon:\n- module.mastodon.aws_iam_instance_profile.mastodon:\n- module.mastodon.aws_iam_policy_attachment.mastodon_ecs_ec2_instance:\n- module.mastodon.aws_iam_policy_attachment.mastodon_ecs_service:\n- module.mastodon.aws_iam_role.mastodon_ec2:\n- module.mastodon.aws_iam_role.mastodon_ecs:\n- module.mastodon.aws_internet_gateway.mastodon:\n- module.mastodon.aws_launch_configuration.mastodon:\n- module.mastodon.aws_route_table_association.mastodon_a:\n- module.mastodon.aws_route_table_association.mastodon_c:\n- module.mastodon.aws_route_table.mastodon:\n- module.mastodon.aws_security_group.mastodon_alb:\n- module.mastodon.aws_security_group.mastodon_db:\n- module.mastodon.aws_security_group.mastodon_elasticache:\n- module.mastodon.aws_security_group.mastodon_web:\n- module.mastodon.aws_subnet.mastodon_private_a:\n- module.mastodon.aws_subnet.mastodon_private_c:\n- module.mastodon.aws_subnet.mastodon_public_a:\n- module.mastodon.aws_subnet.mastodon_public_c:\n- module.mastodon.aws_vpc.mastodon:\n\n## Contributing\n\nPull Requests are welcome if you found bugs or features you think are missing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr7kamura%2Fmastodon-terraform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr7kamura%2Fmastodon-terraform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr7kamura%2Fmastodon-terraform/lists"}