{"id":29416336,"url":"https://github.com/otaku-lt/otaku.lt-sdk","last_synced_at":"2026-05-15T12:35:26.666Z","repository":{"id":303166893,"uuid":"1014599003","full_name":"otaku-lt/otaku.lt-sdk","owner":"otaku-lt","description":"Infrastructure as Code for otaku.lt using Terraform","archived":false,"fork":false,"pushed_at":"2025-07-06T03:40:40.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-06T04:40:32.528Z","etag":null,"topics":["github","iac","infrastructure","terraform"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otaku-lt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-06T03:25:12.000Z","updated_at":"2025-07-06T03:40:43.000Z","dependencies_parsed_at":"2025-07-06T04:40:34.006Z","dependency_job_id":"9aba4817-7100-4064-baf4-50ad66bbbd24","html_url":"https://github.com/otaku-lt/otaku.lt-sdk","commit_stats":null,"previous_names":["otaku-lt/otaku.lt-sdk"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/otaku-lt/otaku.lt-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otaku-lt%2Fotaku.lt-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otaku-lt%2Fotaku.lt-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otaku-lt%2Fotaku.lt-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otaku-lt%2Fotaku.lt-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otaku-lt","download_url":"https://codeload.github.com/otaku-lt/otaku.lt-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otaku-lt%2Fotaku.lt-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264878580,"owners_count":23677451,"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":["github","iac","infrastructure","terraform"],"created_at":"2025-07-11T19:02:58.128Z","updated_at":"2026-05-15T12:35:21.610Z","avatar_url":"https://github.com/otaku-lt.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# otaku.lt-sdk\n\nInfrastructure as Code for otaku.lt using Terraform and Cloudflare Workers.\n\n## Overview\n\nThis project manages the complete infrastructure for [otaku.lt](https://otaku.lt), a Next.js website deployed on Cloudflare Workers. The infrastructure uses Terraform for infrastructure management and Wrangler for deployment automation.\n\n### Key Features\n\n- 🌟 **Cloudflare Workers** deployment\n- 🏗️ **Terraform** infrastructure management\n- 🚀 **Automated CI/CD** with GitHub Actions\n- 📦 **Wrangler** deployment automation\n- 🔒 **Secure authentication** via environment variables\n- 🌐 **Custom domain** with SSL/TLS\n\n## Structure\n\n- `providers.tf` - Terraform, GitHub, and Cloudflare provider configuration\n- `variables.tf` - Input variables for configuration\n- `workers.tf` - Cloudflare Workers configuration\n- `cloudflare.tf` - Legacy configuration (deprecated)\n- `github.tf` - GitHub repository resources\n- `outputs.tf` - Output values\n- `Makefile` - Project automation and deployment commands\n- `.env.example` - Environment variables template\n\n## Prerequisites\n\n1. **Install required tools:**\n   ```bash\n   # On macOS using Homebrew\n   brew install terraform\n   brew install gh\n   brew install cloudflare-wrangler\n   ```\n\n2. **Authenticate:**\n   ```bash\n   gh auth login      # GitHub authentication\n   # Get API token from: https://dash.cloudflare.com/profile/api-tokens\n   ```\n\n## Quick Start\n\n1. **Setup environment:**\n   ```bash\n   make workers-setup\n   ```\n\n2. **Deploy everything:**\n   ```bash\n   make workers-apply\n   ```\n\nThat's it! Your site should be live at https://otaku.lt\n\n## Step-by-Step Setup\n\n### 1. Authentication \u0026 Credentials\n\n```bash\n# Authenticate with both services\ngh auth login\n\n# Set up Cloudflare API token (get from dashboard)\nmake cf-set-token TOKEN=your_api_token_here\n```\n\n### 2. Infrastructure Management\n\n```bash\n# Review infrastructure changes\nmake plan\n\n# Apply infrastructure (Workers, DNS, etc.)\nmake apply\n```\n\n### 3. Deploy Website\n\n```bash\n# Build and deploy to Workers\nmake workers-deploy\n\n# OR deploy to preview/staging\nmake workers-deploy-preview\n```\n## Available Commands\n\n### 🏗️ Infrastructure Management\n- `make setup` - Setup environment and check dependencies  \n- `make plan` - Run terraform plan\n- `make apply` - Run terraform apply  \n- `make fmt` - Format terraform files\n- `make validate` - Validate configuration\n- `make clean` - Clean terraform cache\n\n### 🚀 Workers Deployment\n- `make workers-build` - Build Next.js application\n- `make workers-deploy` - Deploy to production Workers\n- `make workers-deploy-preview` - Deploy to preview/staging\n- `make workers-test` - Test Workers locally\n- `make workers-setup` - Complete Workers setup\n- `make workers-apply` - Apply infrastructure + deploy\n- `make workers-status` - Check deployment status\n\n### 🔧 Utilities\n- `make cf-set-token TOKEN=xyz` - Set Cloudflare API token from dashboard\n- `make cf-set-token TOKEN=xyz` - Set custom API token\n- `make help` - Show all available commands\n\n## Authentication\n\n**🔒 Secure Authentication via Environment Variables**\n\nThe Makefile automatically handles authentication:\n\n### Automatic Setup (Recommended):\n```bash\n# Authenticate with GitHub\ngh auth login\n\n# Set up API token (get from Cloudflare dashboard)\nmake cf-set-token TOKEN=your_api_token_here\n```\n\n### Manual API Token Setup:\n```bash\n# Create custom API token at: https://dash.cloudflare.com/profile/api-tokens\n# Required permissions: Zone:Zone:Read, Zone:DNS:Edit, Account:Cloudflare Workers:Edit\nmake cf-set-token TOKEN=your_custom_api_token\n```\n\n## Configuration\n\nThe project uses `.env` file for configuration (set up with `make cf-set-token`):\n\n```bash\n# Example .env file (auto-generated)\nCLOUDFLARE_API_TOKEN=your_api_token\nCLOUDFLARE_ZONE_ID=your_zone_id  \nCLOUDFLARE_ACCOUNT_ID=your_account_id\nDOMAIN_NAME=otaku.lt\nPAGES_PROJECT_NAME=otaku-lt\n```\n\n## Resources Managed\n\nThis Terraform configuration manages:\n\n### GitHub Resources:\n- **otaku.lt**: Main website repository (Next.js application)\n- **otaku.lt-sdk**: Infrastructure as Code repository (this repository)\n\n### Cloudflare Workers Resources:\n- **Worker Script**: Main application handler with static asset serving\n- **Custom Domains**: DNS configuration for otaku.lt and www.otaku.lt\n- **Worker Routes**: Traffic routing and WWW redirect\n- **SSL/TLS**: Security and performance settings\n- **DNS Records**: A records pointing to Workers\n\n## Deployment Flow\n\n### Workers Flow:\n1. **Code Push** → GitHub repository (otaku.lt)\n2. **GitHub Actions** → Builds Next.js app and deploys to Workers\n3. **Workers** → Serves static assets and handles routing\n4. **Live Site** → https://otaku.lt\n\n### Manual Deployment:\n1. **Build** → `make workers-build` \n2. **Deploy** → `make workers-deploy`\n3. **Live Site** → https://otaku.lt\n\n## Environment Variables\n\nThe project uses these environment variables (managed in `.env`):\n\n```bash\n# Cloudflare (set using cf-set-token)\nCLOUDFLARE_API_TOKEN=your_api_token\nCLOUDFLARE_ZONE_ID=your_zone_id\nCLOUDFLARE_ACCOUNT_ID=your_account_id\n\n# Project configuration\nDOMAIN_NAME=otaku.lt\nPAGES_PROJECT_NAME=otaku-lt\n\n# GitHub (handled automatically by Makefile)\nGITHUB_TOKEN=$(gh auth token)\nGITHUB_OWNER=otaku-lt\n```\n\n## Frontend Configuration\n\nThe Next.js application includes:\n\n### wrangler.toml\n```toml\nname = \"otaku-lt\"\nmain = \"src/index.js\"\ncompatibility_date = \"2024-01-15\"\n\n[assets]\ndirectory = \"out\"\nserve_single_page_app = true\n```\n\n### package.json Scripts\n```json\n{\n  \"scripts\": {\n    \"deploy\": \"npm run build \u0026\u0026 wrangler deploy\",\n    \"deploy:preview\": \"npm run build \u0026\u0026 wrangler deploy --env preview\",\n    \"wrangler:dev\": \"wrangler dev\"\n  }\n}\n```\n\n## CI/CD with GitHub Actions\n\nAutomatic deployment is configured via `.github/workflows/deploy.yml`:\n\n- **Pull Requests**: Deploy to preview environment\n- **Main Branch**: Deploy to production  \n\n### **🔐 Automated Secrets Management**\n\nThe required GitHub Actions secrets are automatically managed by Terraform:\n\n```bash\n# Setup GitHub Actions secrets for CI/CD\nmake github-secrets\n```\n\nThis creates the following repository secrets:\n- `CLOUDFLARE_API_TOKEN` - Your Cloudflare API token\n- `CLOUDFLARE_ACCOUNT_ID` - Your Cloudflare account ID\n\n### **🚀 Complete CI/CD Setup**\n\n```bash\n# Full automated setup\ngh auth login              # Authenticate with GitHub\ngh auth login              # Authenticate with GitHub\n# Get API token from: https://dash.cloudflare.com/profile/api-tokens  \nmake cf-set-token TOKEN=xyz  # Set up credentials\nmake workers-setup         # Setup infrastructure\nmake github-secrets        # Configure CI/CD secrets\nmake workers-apply         # Deploy everything\n```\n\nAfter this setup, your CI/CD pipeline will automatically:\n- Deploy previews for pull requests\n- Deploy to production when merging to main\n- Comment on PRs with preview URLs\n\n## Getting Cloudflare Values\n\n1. **Account ID**: Cloudflare Dashboard → Right sidebar\n2. **Zone ID**: Cloudflare Dashboard → Your domain → Right sidebar\n3. **API Token**: Use `make cf-set-token TOKEN=xyz` or create at [API Tokens](https://dash.cloudflare.com/profile/api-tokens)\n\nFor custom tokens, required permissions:\n- `Zone:Zone:Read`\n- `Zone:DNS:Edit` \n- `Account:Cloudflare Workers:Edit`\n\n## Project Structure\n\n```\notaku.lt-sdk/              # Infrastructure\n├── workers.tf             # Workers configuration\n├── cloudflare.tf          # Legacy configuration (deprecated)\n├── providers.tf           # Provider configuration\n├── variables.tf           # Variable definitions\n├── outputs.tf            # Output definitions\n├── Makefile              # Automation commands\n├── .env                  # Credentials (auto-generated)\n└── README.md             # This file\n\notaku.lt/                  # Frontend Application\n├── wrangler.toml         # Workers configuration\n├── src/index.js          # Worker script\n├── .github/workflows/    # CI/CD\n├── package.json          # Updated with Wrangler\n├── next.config.js        # Next.js configuration\n└── ... (Next.js app)\n```\n\n## Development Workflow\n\n### Local Development:\n```bash\ncd otaku.lt\nnpm run dev              # Next.js dev server\n# OR\nmake workers-test        # Test Workers locally\n```\n\n### Deployment:\n```bash\nmake workers-deploy      # Deploy to production\nmake workers-deploy-preview  # Deploy to staging\n```\n\n### Infrastructure Changes:\n```bash\nmake plan               # Review changes\nmake apply              # Apply changes\n```\n\n## Troubleshooting\n\n### Common Issues:\n\n1. **Authentication errors:**\n   ```bash\n   make cf-set-token TOKEN=your_api_token_here\n   ```\n\n2. **Build failures:**\n   ```bash\n   cd otaku.lt\n   npm install\n   npm run build\n   ```\n\n3. **Deployment issues:**\n   ```bash\n   make workers-status     # Check deployment status\n   wrangler tail           # View logs\n   ```\n\n4. **DNS issues:**\n   ```bash\n   make plan               # Check Terraform DNS config\n   ```\n\n## Security Notes\n\n- Never commit `.env` or files containing sensitive data\n- The `.gitignore` file excludes sensitive files\n- Use remote state backend for production use\n- Rotate API tokens regularly\n\n## Contributing\n\nWhen making changes:\n\n1. **Test locally**: `make workers-test`\n2. **Review infrastructure**: `make plan`\n3. **Deploy preview**: `make workers-deploy-preview`\n4. **Apply to production**: `make workers-apply`\n5. **Commit changes** to both `otaku.lt` and `otaku.lt-sdk`\n\n## Resources\n\n- [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)\n- [Wrangler CLI Documentation](https://developers.cloudflare.com/workers/wrangler/)\n- [Next.js on Workers](https://developers.cloudflare.com/workers/frameworks/framework-guides/nextjs/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotaku-lt%2Fotaku.lt-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotaku-lt%2Fotaku.lt-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotaku-lt%2Fotaku.lt-sdk/lists"}